2015-04-20 14:16:31 -05:00
# uiButton
uiButton is a control which represents a clickable button.
Windows | Unix | OS X
-----|-----|-----
||
2015-04-20 14:25:46 -05:00
uiButton derives from [uiControl ](uiControl.md ).
2015-04-20 14:29:06 -05:00
## constructor NewButton()
2015-04-20 14:25:46 -05:00
```c
uiButton *uiNewButton(const char *text);
```
Creates a new uiButton with the specifed text.
2015-04-20 14:27:45 -05:00
## func Text()
2015-04-20 14:25:46 -05:00
```c
char *uiButtonText(uiButton *b);
```
Returns the text shown on the uiButton. Free the returned string with `uiTextFree()` .
2015-04-20 14:27:45 -05:00
## func SetText()
2015-04-20 14:25:46 -05:00
```c
void uiButtonSetText(uiButton *b, const char *text);
```
Changes the text shown on the uiButton to the given text string.
2015-04-20 14:29:06 -05:00
## func OnClicked()
2015-04-20 14:25:46 -05:00
```c
2015-04-21 19:02:25 -05:00
void uiButtonOnClicked(uiButton *b, void (*handler)(void *sender, void *data), void *data);
2015-04-20 14:25:46 -05:00
```
2015-04-22 10:47:44 -05:00
Sets the function that is called when the user clicks the uiButton. If a handler was previously assigned, this call replaces the old handler with the given one.
2015-04-21 19:02:25 -05:00
2015-04-22 10:47:44 -05:00
The `sender` argument to the callback is the `b` argument to `uiButtonOnClicked()` . It is of type `void *` to allow uiMenuItems to use the same callback functions.
2015-04-21 19:02:25 -05:00
The `data` argument to the callback is the `data` argument to `uiButtonOnClicked()` .
2015-04-20 14:25:46 -05:00
The default handler does nothing.
TODO allow NULL to return to default?