back to gui
wxButton
generated from ../src/mod_gui/control/button.cpp
A button is a control that contains a text string,
and is one of the commonest elements of a GUI. It may
be placed on a dialog box or panel, or indeed almost any other window.
An example:
// dlg is a wxDialog
var button = new wxButton(dlg, -1, "Click me");
button.onClicked = function(event)
{
wxMessageBox("You've clicked me");
}
Constants
Style
| Name |
Description |
| LEFT |
Left-justifies the label. Windows and GTK+ only.
|
| RIGHT |
Right-justifies the bitmap label. Windows and GTK+ only.
|
| TOP |
Aligns the label to the top of the button. Windows and GTK+ only.
|
| BOTTOM |
Aligns the label to the bottom of the button. Windows and GTK+ only.
|
| EXACTFIT |
Creates the button as small as possible instead of making it of the
standard size (which is the default behaviour ).
|
| NO_BORDER |
Creates a flat button. Windows and GTK+ only.
|
| AUTODRAW |
If this is specified, the button will be drawn automatically using
the label bitmap only, providing a 3D-look border. If this style is not
specified,
the button will be drawn without borders and using all provided bitmaps.
WIN32 only.
|
Class Properties
| Name |
Type |
Description |
defaultSize  |
Integer |
Gets the default size of a button.
|
Constructor
wxButton
wxButton()
wxButton(Parent,
Id,
Text,
Pos = wxDefaultPosition,
Size = wxDefaultSize,
Style = wxButton.AUTODRAW,
Validator = wxDefaultValidator)
| Name |
Type |
Default |
Description |
| Parent |
wxWindow |
|
The parent of the button. |
| Id |
Integer |
|
An window identifier. Use -1 when you don't need it.
|
| Text |
String |
|
The label of the button |
| Pos |
wxPoint |
wxDefaultPosition |
The position of the button on the given parent.
|
| Size |
wxSize |
wxDefaultSize |
The size of the button.
|
| Style |
Integer |
wxButton.AUTODRAW |
The button style
|
| Validator |
wxValidator |
wxDefaultValidator |
|
Constructs a new wxButton object.
Properties
| Name |
Type |
Description |
| label |
String |
Get/Set the label of the button.
|
Methods
create
create(Parent,
Id,
Text,
Pos = wxDefaultPosition,
Size = wxDefaultSize,
Style = wxButton.AUTODRAW,
Validator = wxDefaultValidator) : Boolean
| Name |
Type |
Default |
Description |
| Parent |
wxWindow |
|
The parent of the button. |
| Id |
Integer |
|
An window identifier. Use -1 when you don't need it.
|
| Text |
String |
|
The label of the button |
| Pos |
wxPoint |
wxDefaultPosition |
The position of the button on the given parent.
|
| Size |
wxSize |
wxDefaultSize |
The size of the button.
|
| Style |
Integer |
wxButton.AUTODRAW |
The button style
|
| Validator |
wxValidator |
wxDefaultValidator |
|
Creates a button.
setDefault
setDefault()
This sets the button to be the default item for the panel or dialog box.
see defaultItem.
Events
| onClicked |
Called when the button is clicked. The type of the argument that your
handler receives is wxCommandEvent.
|