Skip to content

form.addButton

since 1.5.10

Add a button to the current form.

form.addButton(line, rect, params)

Parameters

Name Type Required Description
line FormLine yes the line where the field should be added
rect Rect yes the coordinates
params table yes see the fields below

Fields of params:

  • text (string): button labem
  • icon (Mask): button bitmap
  • press (function): the function which will be called on button press
  • options (number): text flags like TEXT_LEFT, TEXT_CENTERED, etc.

Returns

The new button

Examples

From the official Ethos documentation
form.addButton(line, nil, {text="Text Button", icon="", press=function() end})

Used in

Real-world usage

Called 92 times across 8 open-source Ethos Lua projects. A few short excerpts:
dashx.app.formNavigationFields['help'] = form.addButton(line, {x = helpOffset, y = y, w = wS, h = h}, {text = "@i18n(app.navigation_help)@", icon = nil, options = FONT_S, paint = function() end, press = function() end})

src/dashx/app/lib/ui.lua:899

if form.addButton then
    form.addButton(backLine, nil, {text = "Back", press = backAction})

src/ethos-arcade/games/retrofight/game.lua:270

if form.addButton then
    form.addButton(bestLine, nil, {text = "Reset", press = resetBest})

src/ethos-flight-training/games/shared/trainer-core.lua:1087