Skip to content

Gui

Immediate-mode GUI (Nuklear): begin/end windows, layout rows, labels, buttons, and string edit. Call each frame from update(dt). All methods are static.

Returns: Bool — Whether the window is visible/open (use to skip drawing content when collapsed or closed).

Parameters:

  • title (String) — Window title.
  • x, y (Num) — Position in pixels (e.g. from top-left of window or design area).
  • w, h (Num) — Width and height in pixels.

Start a window. Call endWindow when done. If the method returns false, you may skip content and still call endWindow().

if (Gui.beginWindow("Settings", 10, 10, 300, 200)) {
Gui.layoutRowDynamic(22, 1)
Gui.label("Volume: %(volume)")
Gui.endWindow()
}

End the current window started with beginWindow. Must be called once per beginWindow each frame.

Parameters:

  • height (Num) — Row height in pixels.
  • cols (Num) — Number of columns (widgets) in the next row.

Layout the next cols widgets in a single row with the given height. Subsequent label/button/edit calls fill the row left to right.

Gui.layoutRowDynamic(28, 4)
if (Gui.buttonLabel("7")) digit(7)
if (Gui.buttonLabel("8")) digit(8)
if (Gui.buttonLabel("9")) digit(9)
if (Gui.buttonLabel("/")) applyOp("/")

Parameters:

  • text (String) — Non-editable label text.

Draw a non-editable label. Use string interpolation for values: Gui.label("FPS: %(fps)").

Returns: Booltrue if the button was clicked this frame.

Parameters:

  • text (String) — Button label.
if (Gui.buttonLabel("Save")) saveGame()
if (Gui.buttonLabel("Quit")) quit()

Returns: String — Current text in the edit field (possibly edited by the user).

Parameters:

  • currentText (String) — Current value to display and edit.
  • maxLen (Num) — Maximum character length (buffer size).

Single-line string edit. Returns the (possibly edited) string; typically you store it in a variable and pass it back next frame.

_widthStr = Gui.editString(_widthStr, 8)
_heightStr = Gui.editString(_heightStr, 8)

Returns: Booltrue if the last edit (e.g. from editString) was committed (e.g. user pressed Enter or focus left the field).

Use to apply or validate when the user “submits” the edit.