The Button class represents a button control which can be added to a window. It can be clicked by the user using the mouse, or activated by the keyboard if the control has keyboard focus. When the button is pushed, the click event is fired.
// create an instance of our derived MyForm class
var f = new MyForm;
f.show();
Application.run();
// create our own class derived from Form
class MyForm extends Form
{
function MyForm()
{
// call the constructor on the base class Form
super("Button Example", 100, 100, 200, 100);
// create a button and add the button to our form
var button = new Button("Exit", 60, 20, 80, 24);
this.add(button);
// when the button is clicked, call the onButtonClicked
// event handler on this class
button.click.connect(this, onButtonClicked);
}
function onButtonClicked()
{
// when the button is clicked, exit the application
Application.exit();
}
}
The button's current label text.
Returns the button's current label text.
Sets a button as a form's 'default' button. A default button is activated whenever the enter key is pressed when a form is focused.
Sets the button's label text to the string specified in the text parameter.