form.addBooleanField¶
since 1.1.0
Add a boolean field to the current form.
Parameters¶
| Name | Type | Required | Description |
|---|---|---|---|
line |
FormLine | yes | the line where the field should be added |
rect |
Rect | yes | the coordinates |
getValue |
function | yes | the function which will return the current value |
setValue |
function | yes | the function which will be called on value change |
Returns¶
The new field
Examples¶
local line = form.addLine("Voice alerts")
form.addBooleanField(line, nil,
function() return config.voice end,
function(v) config.voice = v end)
From the official Ethos documentation
form.addBooleanField(line, nil, function() return value end, function(newValue) value = newValue end)
Used in¶
Real-world usage¶
Called 54 times across 5 open-source Ethos Lua projects. A few short excerpts:
formFieldCount = formFieldCount + 1
dashx.session.formLineCnt = dashx.session.formLineCnt + 1
dashx.app.formLines[dashx.session.formLineCnt] = form.addLine("@i18n(app.modules.settings.txt_devtools)@")
dashx.app.formFields[formFieldCount] = form.addBooleanField(dashx.app.formLines[dashx.session.formLineCnt], nil, function() if dashx.preferences and dashx.preferences.developer then return settings['devtools'] end end,
function(newValue) if dashx.preferences and dashx.preferences.developer then settings.devtools = newValue end end)