Index |
---|
The Button and how to create it The Parameters Button Functions Important Info |
The button inherits from the control class. It is one of the many ways for an application to recieve input. A button is verry common in
GUI applications as a way to get input from a user. When a button is clicked, a callback function is called.
--Button:
f1 = form(10, 10, 100, 100, false, "Main", color.white, color.AirForceBlue, true, false, false, false, false, false, true)
mybutton = button("MB", 1, 1, action, color.black, color.buttoncontrol, f1)
The code is exactly how you would create a button. You must have a form created in order to store you button, as with any other derivative of
the control class. As always you can declare any class two ways and if you dont remember how, read the forms reference here: Forms
The image below shows what the button declared above looks like.
The Buttons parameters are as follows:
Parameter | Description |
---|---|
string text | Sets the buttons text to the string that was entered. |
int x | The x location of the button on the screen. |
int y | The y location of the button on the screen. |
function action | The callback function that is called when a button is clicked. |
color txtcolor | Sets the button's text color. |
color bgcolor | Sets the buttons background color. |
form parent | The form that the button will be visible on. |
If you dont know the keywords, go here: Forms
Here are the diffrent functions that you can call that do something with buttons:
Function | Description | Call example |
---|---|---|
none | none | none |
Buttons resize according to how long its text string is, so if you change the text while the application is running
make sure that the button does not overlap other controls.