Button Class
A region of a `Panel` which causes some action when clicked.
Method Index
- enable(enable)
- handleClick(mouse_button)
- makeRepeat()
- makeToggle()
- preservePanel()
- setDisabledSprite(index)
- setDynamicTooltip(callback, x, y)
- setLabel(label, font, align)
- setPosition(x, y)
- setSize(width, height)
- setSound(name)
- setToggleState(state)
- setTooltip(tooltip, x, y)
- setVisible(visibility)
- toggle()
Member Index
- b
- enabled
- is_repeat
- is_toggle
- on_click
- on_click_self
- on_rightclick
- panel_for_sprite
- panel_lowered_active
- panel_lowered_normal
- r
- sound
- sprite_index_active
- sprite_index_disabled
- sprite_index_normal
- toggled
- tooltip
- ui
- x
- y
function Button:Button()
Declared on: line 600 of Lua/window.lua.
function Button:enable(enable)
Enable or disable a button.
Parameters:
| Name | Type | Description |
|---|---|---|
| enable | boolean | Whether to enable (true) or disable (false) the button. |
Declared on: line 628 of Lua/window.lua.
function Button:handleClick(mouse_button)
this or another button). However for repeat buttons, it is called once on MouseDown and, after
a short delay, repeatedly.
Parameters:
| Name | Type | Description |
|---|---|---|
| mouse_button | string | either "left" or "right" |
Declared on: line 721 of Lua/window.lua.
function Button:makeRepeat()
Declared on: line 656 of Lua/window.lua.
function Button:makeToggle()
Declared on: line 649 of Lua/window.lua.
function Button:preservePanel()
Declared on: line 684 of Lua/window.lua.
function Button:setDisabledSprite(index)
Parameters:
| Name | Type | Description |
|---|---|---|
| index | ? | ? |
Declared on: line 623 of Lua/window.lua.
function Button:setDynamicTooltip(callback, x, y)
Parameters:
| Name | Type | Description |
|---|---|---|
| callback | ? | ? |
| x | ? | ? |
| y | ? | ? |
Declared on: line 712 of Lua/window.lua.
function Button:setLabel(label, font, align)
Convenience function to allow setLabel to be called on a button, not only its panel.
see Panel:setLabel
Parameters:
| Name | Type | Description |
|---|---|---|
| label | ? | ? |
| font | ? | ? |
| align | ? | ? |
Declared on: line 780 of Lua/window.lua.
function Button:setPosition(x, y)
Set the position of a button.
Parameters:
| Name | Type | Description |
|---|---|---|
| x | int | New horizontal position of the button. |
| y | int | New vertical position of the button. |
Declared on: line 745 of Lua/window.lua.
function Button:setSize(width, height)
Set the size of a button.
Parameters:
| Name | Type | Description |
|---|---|---|
| width | int | New width of the button. |
| height | int | New height of the button. |
Declared on: line 760 of Lua/window.lua.
function Button:setSound(name)
Parameters:
| Name | Type | Description |
|---|---|---|
| name | ? | ? |
Declared on: line 691 of Lua/window.lua.
function Button:setToggleState(state)
Set the toggle state of the button to the provided state.
Parameters:
| Name | Type | Description |
|---|---|---|
| state | boolean | Desired state of the toggle button. |
Declared on: line 675 of Lua/window.lua.
function Button:setTooltip(tooltip, x, y)
Specify a tooltip to be displayed when hovering this button.
x and y are optional position of bottom left of the tooltip.
If not specified, will default to top center of button.
Parameters:
| Name | Type | Description |
|---|---|---|
| tooltip | ? | ? |
| x | ? | ? |
| y | ? | ? |
Declared on: line 700 of Lua/window.lua.
function Button:setVisible(visibility)
Set the visibility of the button.
Parameters:
| Name | Type | Description |
|---|---|---|
| visibility | bool | New visibility of the button. |
Declared on: line 773 of Lua/window.lua.
function Button:toggle()
Flip the toggle state of the button (on -> off, or off -> on).
Declared on: line 663 of Lua/window.lua.