Name: | Button |
Version: | 1.0 |
ID: | ID_BUTTON |
Status: | Beta |
Category: | GUI |
Date: | November 2003 |
Author: | Rocklyte Systems |
Copyright: | Rocklyte Systems, 2003. All rights reserved. |
Short: | The Button class manages the display and interactivity of user buttons. |
The Button class simplifies the creation and management of buttons as part of the user interface. New buttons are typically created by declaring the graphical dimensions and the text to be displayed within them. The Button class allows for the specifics of the button to be altered, such as the colours and the font style.
The definitions for new buttons are loaded by default from the environment file "templates:buttondef.xml". You can change the template file prior to initialisation by setting the Template field. Note that any values set by the template will override the existing field settings in the button.
You will need to configure the button so that when it is clicked, it performs an action. There are three acceptable methods that you can use to achieve this. The first is to set the ActionScript field so that it refers to a script that executes when the button is pressed. The second is to initialise child objects to the button and they will be executed on activation. The third option is to listen to the Activate action by calling the SubscribeAction() function on the button.
The following example illustrates how you might create a cancel button in DML. Notice that the Action object is initialised as static and will be executed when the button is clicked:
<button xoffset="[window.leftmargin]" yoffset="[window.bottommargin]" text="Cancel" width="70"> <action static call="free" object="[window]"/> </button>
The Button class supports the following actions:
Activate Activates the button. Disable Turns the button off. Enable Turns the button on if it has been disabled. Focus Sets the focus on the button and activates keyboard monitoring. Hide Removes the button from the display. LostFocus Removes the focus from the button and disables key monitoring. MoveToBack Moves the button to the back of the display area. MoveToFront Moves the button to the front of the display area. Redimension Changes the size and position of the button. Resize Alters the size of the button. Show Puts the button on display. UserClick Emulates a user click on the button. UserClickRelease Emulates a user click on the button. UserClickRepeat Emulates a user click-repeat on the button. UserMovement Emulates user movement over the button.
The Button object consists of the following public fields:
ActionScript A script to be executed when the button is clicked. Bottom The bottom coordinate of the button. ClickFrame The graphics frame to display when the button is clicked. Colour String-based field for setting the colour inside of the button. ColourRGB Defines the internal colour of the button in RGB format. Drawable The drawable that will contain the button graphic. EnterFrame The graphics frame to display when the user's pointer enters the button area. ExitFrame The graphics frame to display when the user's pointer leaves the button area. Flags Optional flags may be set here. Height Defines the height of a button. Highlight String-based field for setting the button highlight. HighlightRGB Defines border highlight of the button, in RGB format. Image The image field can be set in order to load a bitmap into the button. Region The drawable that represents the button is referenced through this field. ReleaseFrame The graphics frame to display when a user-click is released. Right The right coordinate of the button. Shadow String-based field for setting the button shadow. ShadowRGB Defines border shadow of the button, in RGB format. String The string that is to be printed inside the button is declared here. TabFocus Set this field to a TabFocus object to register the button in a tab-list. Template Defines the makeup of the button using a pre-defined template. Thickness The thickness of the button border. Width Defines the width of a button. XCoord The horizontal position of a button. XOffset The horizontal offset of a button. YCoord The vertical position of a button. YOffset The vertical offset of a button.
Field: | Bottom | |
Short: | The bottom coordinate of the button. | |
Type: | LONG | |
Status: | Get | |
|
Field: | ClickFrame | |
Short: | The graphics frame to display when the button is clicked. | |
Type: | LONG | |
Status: | Read/Write | |
|
Field: | Colour | |
Short: | String-based field for setting the colour inside of the button. | |
Type: | STRING | |
Status: | Set | |
|
Field: | ColourRGB | |
Short: | Defines the internal colour of the button in RGB format. | |
Type: | RGB | |
Status: | Read | |
|
Field: | Drawable | |
Short: | The drawable that will contain the button graphic. | |
Type: | OBJECTID | |
Status: | Read/Init | |
|
Field: | EnterFrame | |
Short: | The graphics frame to display when the user's pointer enters the button area. | |
Type: | LONG | |
Status: | Read/Write | |
|
Field: | ExitFrame | |
Short: | The graphics frame to display when the user's pointer leaves the button area. | |
Type: | LONG | |
Status: | Read/Write | |
|
Field: | Flags | |||||||||||
Short: | Optional flags may be set here. | |||||||||||
Type: | LONG | |||||||||||
Status: | Read/Init | |||||||||||
|
Field: | Height | |
Short: | Defines the height of a button. | |
Type: | DOUBLE/PERCENTAGE | |
Status: | Get/Set | |
|
Field: | Highlight | |
Short: | String-based field for setting the button highlight. | |
Type: | STRING | |
Status: | Set | |
|
Field: | HighlightRGB | |
Short: | Defines border highlight of the button, in RGB format. | |
Type: | RGB | |
Status: | Read | |
|
Field: | Image | |
Short: | The image field can be set in order to load a bitmap into the button. | |
Type: | STRING | |
Status: | Set | |
|
Field: | Region | |
Short: | The drawable that represents the button is referenced through this field. | |
Type: | OBJECTID | |
Status: | Read | |
|
Field: | ReleaseFrame | |
Short: | The graphics frame to display when a user-click is released. | |
Type: | LONG | |
Status: | Read/Write | |
|
Field: | Right | |
Short: | The right coordinate of the button. | |
Type: | LONG | |
Status: | Get | |
|
Field: | Shadow | |
Short: | String-based field for setting the button shadow. | |
Type: | STRING | |
Status: | Set | |
|
Field: | ShadowRGB | |
Short: | Defines border shadow of the button, in RGB format. | |
Type: | RGB | |
Status: | Read | |
|
Field: | String | |
Short: | The string that is to be printed inside the button is declared here. | |
Type: | STRING | |
Status: | Get/Set | |
|
Field: | TabFocus | |
Short: | Set this field to a TabFocus object to register the button in a tab-list. | |
Type: | OBJECTID | |
Status: | Set | |
|
Field: | Template | |
Short: | Defines the makeup of the button using a pre-defined template. | |
Type: | STRING | |
Status: | Init | |
|
Field: | Thickness | |
Short: | The thickness of the button border. | |
Type: | LONG | |
Status: | Read/Write | |
|
Field: | Width | |
Short: | Defines the width of a button. | |
Type: | DOUBLE/PERCENTAGE | |
Status: | Get/Set | |
|
Field: | XCoord | |
Short: | The horizontal position of a button. | |
Type: | DOUBLE/PERCENTAGE | |
Status: | Get/Set | |
|
Field: | XOffset | |
Short: | The horizontal offset of a button. | |
Type: | DOUBLE/PERCENTAGE | |
Status: | Get/Set | |
|
Field: | YCoord | |
Short: | The vertical position of a button. | |
Type: | DOUBLE/PERCENTAGE | |
Status: | Get/Set | |
|
Field: | YOffset | |
Short: | The vertical offset of a button. | |
Type: | DOUBLE/PERCENTAGE | |
Status: | Get/Set | |
|