deploy: 5a1ec672a7
This commit is contained in:
@@ -3,6 +3,87 @@ _A clickable interface element that triggers actions when pressed. Supports text
|
||||
|
||||
Extends: `VisualElement`
|
||||
|
||||
## Usage
|
||||
```lua run
|
||||
-- Create a simple action button
|
||||
```
|
||||
|
||||
```lua run
|
||||
local button = parent:addButton()
|
||||
```
|
||||
|
||||
```lua run
|
||||
:setPosition(5, 5)
|
||||
```
|
||||
|
||||
```lua run
|
||||
:setText("Click me!")
|
||||
```
|
||||
|
||||
```lua run
|
||||
:setBackground(colors.blue)
|
||||
```
|
||||
|
||||
```lua run
|
||||
:setForeground(colors.white)
|
||||
```
|
||||
|
||||
```lua run
|
||||
|
||||
```
|
||||
|
||||
```lua run
|
||||
-- Add click handling
|
||||
```
|
||||
|
||||
```lua run
|
||||
button:onClick(function(self, button, x, y)
|
||||
```
|
||||
|
||||
```lua run
|
||||
-- Change appearance when clicked
|
||||
```
|
||||
|
||||
```lua run
|
||||
self:setBackground(colors.green)
|
||||
```
|
||||
|
||||
```lua run
|
||||
self:setText("Success!")
|
||||
```
|
||||
|
||||
```lua run
|
||||
|
||||
```
|
||||
|
||||
```lua run
|
||||
-- Revert after delay
|
||||
```
|
||||
|
||||
```lua run
|
||||
basalt.schedule(function()
|
||||
```
|
||||
|
||||
```lua run
|
||||
sleep(1)
|
||||
```
|
||||
|
||||
```lua run
|
||||
self:setBackground(colors.blue)
|
||||
```
|
||||
|
||||
```lua run
|
||||
self:setText("Click me!")
|
||||
```
|
||||
|
||||
```lua run
|
||||
end)
|
||||
```
|
||||
|
||||
```lua run
|
||||
end)
|
||||
```
|
||||
|
||||
## Properties
|
||||
|
||||
|Property|Type|Default|Description|
|
||||
|
||||
Reference in New Issue
Block a user