| Package | qnx.ui.buttons |
| Class | public class Button |
| Inheritance | Button SkinnableComponent UIComponent flash.display.MovieClip |
| Subclasses | IconButton, LabelButton |
Button class represents a common button.
A button consists of a skin, which changes based on the current state of the button.
You can create a custom skin by implementing the ISkin interface.
A button has an up, down, selected, and disabled state.
The following image shows a Button instance in the up state:
You can also use the toggle property to make the button behave like a toggle switch.
See also
| Property | Defined By | ||
|---|---|---|---|
![]() | containment : String
Gets or sets a property that determines how a component is contained within a parent container. | UIComponent | |
| selected : Boolean
Gets or sets the selected property of the button. | Button | ||
![]() | size : Number
Gets or sets the size for this component (as a percentage of the
container's size, or in pixels). | UIComponent | |
![]() | sizeMode : String
Gets or sets the size mode for this component. | UIComponent | |
![]() | sizeUnit : String
Gets or sets the unit of measure for the size property. | UIComponent | |
| toggle : Boolean
Gets or sets the toggle property of the button. | Button | ||
| Method | Defined By | ||
|---|---|---|---|
Button()
Constructs a Button instance. | Button | ||
![]() | destroy():void
Call this method when you want to have your object collected by the garbage collector. | UIComponent | |
![]() | drawNow():void
Calls the draw() method. | UIComponent | |
![]() | invalidate(property:String, invalidateNow:Boolean = false):void
Marks the property as invalid and the draw() method is called on the next frame or the next render, whichever comes first. | UIComponent | |
![]() | setPosition(x:Number, y:Number):void
Sets the x and y position of the component. | UIComponent | |
![]() | setSize(w:Number, h:Number):void
Sets the width and height of the component. | UIComponent | |
![]() | setSkin(cellSkin:Object):void
Set the skin object on the component for it to render. | SkinnableComponent | |
| selected | property |
selected:BooleanGets or sets the selected property of the button.
The default value is false.
public function get selected():Boolean public function set selected(value:Boolean):void| toggle | property |
toggle:Boolean
Gets or sets the toggle property of the button.
When set to true, the button's selected state is toggled when the button is released. When the user touches the
button, the button remains selected. When the user touches the button again, the button is released.
private function initializeUI():void
{
mySimpleButton = new Button();
mySimpleButton.width = 100;
mySimpleButton.setPosition(30, 30);
mySimpleButton.toggle = true;
mySimpleButton.selected = true;
this.addChild(mySimpleButton);
}
The default value is false.
public function get toggle():Boolean public function set toggle(value:Boolean):void| Button | () | Constructor |
public function Button()
Constructs a Button instance.