Add XML usage to schedule.md

This commit is contained in:
Sabine Lim
2023-05-08 02:35:33 +10:00
committed by GitHub
parent c084e9e5ad
commit 2f09e12ec2

View File

@@ -15,7 +15,7 @@ Schedules a function which gets called in a coroutine. After the coroutine is fi
### Usage
* Creates a schedule which switches the color between red and gray
Creates a schedule which switches the color between red and gray:
```lua
local mainFrame = basalt.createFrame()
@@ -34,3 +34,18 @@ aButton:onClick(basalt.schedule(function(self)
self:setBackground(colors.gray)
end))
```
Usage in XML layout:
```xml
<button text="Click me">
<onClick>
basalt.schedule(function()
local button = event[1]
button:setBackground(colors.lime)
os.sleep(1)
button:setBackground(colors.black)
end)()
</onClick>
</button>
```