-- GUI input: a form (text field, slider, select, checkbox, buttons) in a GUI that takes input; -- guiSetHandler routes the elements' click, change and submit events to script functions, which -- report through guiSetValue and debugPrint. The mouse, keys, text entry and the framework -- switches (a pad's directions and ACTION_1 / ACTION_2 as Return and Escape) all reach the GUI -- before the game; what a document uses never arrives as onInputPressed. Headless the scene -- proves the handler path by dispatching a click through RmlUi's own Lua API, and the by-id -- helpers by writing and reading the text field. local font = fontLoad("Singe/FreeSansBold.ttf", 24) local frames = 0 local clicks = 0 fontSelect(font) overlaySetResolution(discGetWidth(), discGetHeight()) local gui = guiNew(overlayGetWidth(), overlayGetHeight()) local doc = guiLoad(gui, "testScripts/scene38.rml") guiSetInput(gui, true) local function report(what) guiSetValue(gui, doc, "status", what) debugPrint("scene38 " .. what) end guiSetHandler(gui, doc, "go", "click", function(g, d, id, event, value) clicks = clicks + 1 report("Start clicked " .. clicks .. ": name=" .. guiGetValue(g, d, "name") .. " volume=" .. guiGetValue(g, d, "volume") .. " difficulty=" .. guiGetValue(g, d, "difficulty")) end) guiSetHandler(gui, doc, "back", "click", function() report("Back clicked") end) guiSetHandler(gui, doc, "volume", "change", function(g, d, id, event, value) report("volume " .. value) end) guiSetHandler(gui, doc, "difficulty", "change", function(g, d, id, event, value) report("difficulty " .. value) end) function onInputPressed(what) debugPrint("scene38 onInputPressed " .. what .. " (the GUI did not use it)") end function onOverlayUpdate() frames = frames + 1 overlayClear() colorForeground(255, 255, 255, 255) fontPrint(10, overlayGetHeight() - 30, "scene38 frame " .. frames) guiDraw(gui) if frames == 30 then -- Headless: press Start through RmlUi's Lua API, as a mouse click would. rmlui.contexts["gui0"].documents["scene38"]:GetElementById("go"):DispatchEvent("click", {}) elseif frames == 60 then guiSetValue(gui, doc, "name", "Daphne") guiSetValue(gui, doc, "volume", "85") report("name is now " .. guiGetValue(gui, doc, "name") .. ", volume " .. guiGetValue(gui, doc, "volume")) elseif frames == 70 then rmlui.contexts["gui0"].documents["scene38"]:GetElementById("go"):DispatchEvent("click", {}) elseif frames == 80 or frames == 100 then singeScreenshot() elseif frames == 110 then singeQuit() end return OVERLAY_UPDATED end