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.
Gui.beginWindow(title, x, y, w, h)
Section titled “Gui.beginWindow(title, x, y, w, h)”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()}Gui.endWindow()
Section titled “Gui.endWindow()”End the current window started with beginWindow. Must be called once per beginWindow each frame.
Gui.layoutRowDynamic(height, cols)
Section titled “Gui.layoutRowDynamic(height, cols)”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("/")Gui.label(text)
Section titled “Gui.label(text)”Parameters:
text(String) — Non-editable label text.
Draw a non-editable label. Use string interpolation for values: Gui.label("FPS: %(fps)").
Gui.buttonLabel(text)
Section titled “Gui.buttonLabel(text)”Returns: Bool — true if the button was clicked this frame.
Parameters:
text(String) — Button label.
if (Gui.buttonLabel("Save")) saveGame()if (Gui.buttonLabel("Quit")) quit()Gui.editString(currentText, maxLen)
Section titled “Gui.editString(currentText, maxLen)”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)Gui.lastEditCommitted()
Section titled “Gui.lastEditCommitted()”Returns: Bool — true 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.