ui_button
result = ui_button(label, [id=])
Input: label, id · Output: result
What it is
Declares a push-button, labeled label (string); id= (string) as above.
Overloads
One call shape — this function is not overloaded.
| Code | Input | Output | Description |
result = ui_button(label, [id=]) | label stringDeclares a push-button, labeled label (string).id string, optionalid= (string) as above. | result — | Returns true only on the run the host reports it as pressed, false otherwise — it does not stay true on later re-runs, so if ui_button("Reset") ... end reads naturally. Unlike the other UI widgets, it takes no default=. |
Examples
From the documentation, and run by the build -- the output and the figure below are what the engine actually produced. Simplest first.
freq = ui_slider("freq", 1, 20, 5)
gain = ui_number("gain", 1.0)
mode = ui_select("mode", ["fast", "slow"])
enabled = ui_checkbox("enabled", true)
pressed = ui_button("reset")
label = ui_text("label", "wave")
print(freq)
print(gain)
print(mode)
print(enabled)
print(pressed)
print(label)
output
5 1 fast true false wave
from plotting
How it works
ui_button(label, [id=]) -- true only on the run the host reports it as pressed, so if ui_button("Reset") ... end reads naturally and doesn't latch on for every subsequent re-run.
From the note above this builtin in the interpreter, where the reasoning was written down as it was built.