Skip to content

Button

extends Element

Button: clickable element with centered text and pressed feedback. While the mouse button is held, foreground and background swap ("pressed" state); the click event fires on press.

Properties

PropertyTypeDefaultDescription
textany"Button"Label text, rendered centered
widthnumber10Width in terminal cells
heightnumber3Height in terminal cells
backgroundnumber|falsecolors.grayBackground color (false = transparent)

Methods

Button:render(buf)

Renders the button into the buffer.

  • buf (Render) The render buffer (local coordinates, pre-clipped)

Button:measure()

Intrinsic size for basalt.auto(): text width + padding, 3 rows.

  • returns width (number) The measured width
  • returns height (number) The measured height
lua
local btn = frame:addButton({ width = basalt.auto(), text = "Ok" })

Last updated:

Released under the MIT License.