Button

Note

Button is derived from Control class.

A Button is a control that contains a text string, and is one of the most common elements of a GUI.


Constructor

Button class has a complex constructor:

object Button:new {
               number ID, string Name,
               object Parent, Text = 'My Button'
       }

Events

The following events are emitted by this class:

Event name Description
Widget.onEnter When the mouse moves onto this widget.
Widget.onLeave When the mouse moves out to this widget.
Button.onClick_ When the user clicks on this button.

Inherited Methods

These methods are inherited from its super classes:

Class Method Description
Object:getID Returns object’s identifier.
Object:setID Sets the object identifier.
Object:getName Returns object’s name.
Object:setName Sets the object name.
Widget:getParent Returns object’s parent.
Widget:setParent Sets the object parent.
Widget:getPosX Returns object’s position related to X.
Widget:setPosX Sets the object position related to X.
Widget:getPosY Returns object’s position related to Y.
Widget:setPosY Sets the object position related to Y.
Widget:getWidth Returns object’s width.
Widget:setWidth Sets the object width.
Widget:getHeight Returns object’s height.
Widget:setHeight Sets the object height.
Widget:getwxObj Returns the wxWidgets object.

Button:getText

Returns the button’s text, as it was passed to setText()

Note that the returned string may contains mnemonics (“&” characters) if they were passed to the setText() function; use getText(false) if they are undesired.

Also note that the returned string is always the string which was passed to setText().

Reimplemented from wxWindow.

string Control:getText( bool bMnemonics = true )

Button:setText

Sets the control’s label.

All “&” characters in the label are special and indicate that the following character is a mnemonic for this control and can be used to activate it from the keyboard (typically by using Alt key in combination with it). To insert a literal ampersand character, you need to double it, i.e. use “&&”. If this behaviour is undesirable, use setText(text, false) instead.

bool Control:setText( string sNewText, bMnemonics = true )