Button class definitio. To decorate a Button in application. It defines onCleck event, what suppose to happen when user clicked on button. It supports normal state, pressed and disabled state. Appearance of all states are defined in Skin theme.
Example
include "lib://uix-skin/metro/skin.metro.ms" include "lib://uix/application.ms" include "lib://uix/form.ms" var app = new Application({skin: new MetroSkin()}); var quit = false; app.onStart = function(sender) { var form = new Form(); app.add(form); //TODO: to example // normal button var button = new Button({text : "Button text"}); // onClick event button.onClick = function() { logI("button click"); } form.add(button); // disapled button var buttonB = new Button({ text : "Button disabled", enabled : false, // onClick event is not called when user click to the button if it is disabled onClick : function() { logI("button click"); } }); form.add(buttonB); // button with changed background and image var buttonC = new Button({ text : "Green button", bg : { color: 0xff0F9E4D}, onClick : function() { logI("button click"); } }); form.add(buttonC); } app.onProcess = function(sender) { return quit ? 0 : 1; } app.onKeyPressed = function(sender, key) { quit = true; } app.onDraw = function(sender, canvas) { canvas.clear(0xffdadada); } app.init().run();
Properties
-
align : Symbol
Align of button components.
-
bg : BGDrawing
Background drawing, it holds instance of BGDrawing to decorate background.
-
bgPressed : BGDrawing
-
border : Drawing
Border drawing, it holds instance of Drawing to decorate border.
-
clicked : Boolean
Clicked flag.
-
clipToBounds : Boolean
Set/Get if the view is not clipped to its bounds.
-
defaults : Object
Sets default controls options.
-
detach : UIX.View
Remove this view form it's parent.
-
disabled : Pattern
Disabled pattern property, it defines what drawing is used when Button is disabled. Pattern specify Foreground, bacgkround and border paints
-
enabled : Boolean
Flag to enable/disable Button.
-
fg : TextDrawing
Foreground drawing, it holds instance of TextDrawing object to decorate text of Control.
-
fgPressed : TextDrawing
-
height : Integer
Height of the Control (in pixels).
-
image : Image
Image property, to set bitmap or vector picture to the Button.
-
initialisation : Boolean
Initialisation in progress.
-
label : Label
Button Label definition.
-
layout : StackLayout
StackLayout used to layout elements into the object.
-
left : Integer
X - coordinates of Control's position.
-
name : String
Name of the Control.
-
native : Any
Native, instance of native UI object(View,ScrollView,Window).
-
options : Object
Position of navigation bar.
-
parent : Any
Parent, instance of native UI object where current Control is assigned. Basicaly is a container where control was added.(View,ScrollView,>Window)
-
pressed : Pattern
Pressed pattern property, it defines what drawing is used when Button is clicked. Pattern specify Foreground, bacgkround and border paints
-
skipDrawing : Boolean
Skip control drawing. It used if control is part of composite control what manage drawing bu itself.
-
stretch : Symbol
Gets or sets if the view's width is stretchable.
-
text : String
Text of button label.
-
this
Construct of the object calls following method in order.
-
top : Integer
Y - coordinates of control's position.
-
visible : Boolean
Visibility of the Control. Default is True.
-
width : Integer
Width of the Control (in pixels).
Methods
-
add(control,order = #front)
Add Control to container.
-
afterInit()
After Init Control, set control defaults from current theme setting.
-
afterInitControls
Method is executed after init controls.
-
beforeInit()
After Init Control, set control defaults from current theme setting.
-
beforeInitControls
Method is executed before init controls.
-
find(name) : Control
Search for child Controls, which name is same as name from function's param.
-
focusable() : Boolean
Ability to have a focus.
-
getChildrenBounds() : MultiValue
Returns four values (left, top, right, bottom) of child's union content.
-
getChildrenSize() : MultiValue
Returns two values (width, height) of child's union content.
-
hasFocus() : Boolean
Returns true if this Control has focus. Otherwise, function returns false.
-
icon(width, height) : Control
Icon, other way how o set control image. It accept symbol of vector, location to bitmap, instance of bitmap or instance of path. This property can be used only if image is defined.
-
init()
Button init controls.
-
invalidate()
This function ensure redrawing a rectangle, determined by parameters. Redrawing manages the function, which is set to onDraw event.
-
isImage() : Boolean
Is image test. Return true if image instance is set
-
performLayout()
Performs (force) layout calculations.
-
removeAll()
Remove all child controls from container.
-
resumeLayout()
Resume layer's recalculating.
-
setFocus() : Control
Function sets focus to the Control.
-
setLocation(left, top) : Control
Function to set control left and top position.
-
setSize(width, height) : Control
Function to set width and hight of control.
-
suspendLayout()
Pause layer's recalculating.
-
undefined(k,v)
Special property executed when priperty is undefined. It can be that JSON format is in format "key" : "value". Key is an string, so if this is the case methot return "value". Ass well as k is a regular property of the class it returns getter of this property.
Events
-
onChar(sender,charCode) : Function
This event is raised by release an UNICODE character key.
-
onClick(sender) : Function
On click event.
-
onDraw(sender,canvas) : Function
This event occurs, when it is necessary to redraw object. onDraw event is usually managed by skin.
-
onKeyPressed(sender,key) : Function
This event is raised by press the key.
-
onKeyReleased(sender,key) : Function
This event is raised by release the key.
-
onPointerDragged(sender,x,y) : Function
Called when touch (click) is moved.
-
onPointerPressed(sender,x,y) : Fucntion
Called when touch (click) is stared.
-
onPointerReleased(sender,x,y) : Function
Called when touch (click) is finished.
-
onProcess : Function
Callback function, which is called from the object every 25ms.
-
onResize(sender,charCode) : Function
Occurs when the control is resized.
|
|
|
 |
Badge
|
|
|
 |
Button
|
|
|
 |
CheckBox
|
|
|
 |
Image
|
|
|
 |
Label
|
|
|
 |
Row
|
|
|
 |
SwitchControl
|
|
|
 |
TextBox
|
|
 |
Application
|
|
 |
Controller
|
|
 |
Form
|
|
 |
Model
|
|