Add XML usage to schedule.md #59

Merged
thesabinelim merged 1 commits from patch-2 into master 2023-05-08 00:36:57 +08:00

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>
```