How can i create a textbox and a phone keyboard to use in my quiz game using lua?


Hi,…another question…can anyone guide me on how to add a textbox on my quiz game?..and when the user tap the textbox,…a mobile keayboard will apeear to input the correct answer…thanks in advance!

1 Like



There are no builtin GUI text input elements, but you could take a look at my mini-library: DirtyLarry - A quick and dirty GUI library

In summary:
The input “element” is just a text GUI node. I check for mouse clicks/touches on this node and show the system keyboard if this happen (gui.show_keyboard()). When any “text input” is received, I update the content of the text node (gui.set_text()).



@sven Thanks for the link of dirty larry…i actually used it on my game and it looks awesome(really!)…but one more thing: i dont know why i cant get any user inputs from the buttons and text input…

– i actually set “acquire_input_focus” on the “function_init()”,…
– added the gui_script to the gui_scene,…
– i tried also to add touch events in the input binding…
– set the whole line of codes to the “function on_input()”
– tried to run the bundled app to my smartphone and even in my desktop pc(windows 7) … but no luck…

is there something that i had missed?..any help from you is very appreciated…thanks!



Do you have the correct input bindings? Are you using any proxy collections and if so, are all parts of the input stack acquiring input focus?

1 Like


@britzl This is the whole code that i had used on my gui script that was attached to my gui scnene…i only tried follow what sven actually said…but maybe,…i missed something important on it…

gui_script code:

local dirtylarry = require "dirtylarry/dirtylarry"

function init(self)".", "acquire_input_focus")


function on_input(self, action_id, action)

self.input_default = dirtylarry:input("txtgLvl1", action_id, action, gui.KEYBOARD_TYPE_DEFAULT, "Type your answer here...")

dirtylarry:button("btnSubmitLvl1", action_id, action, function ()
print("Input: " .. tostring(self.input_default))


I actually didn’t use any collection proxy this time…i only use one collection file which is the MAIN.collection …what i wanted to do is to do all the stuff using gui scenes and gui scripts only…

I actually add “touch” and “click” input bindings on my project…BUT im afraid as i do not know how to use it this time…coz the current code that i am using is different from the actual code that i had used before like this:

if action_id == hash("touch") and action.released and gui.pick_node(gui.get_node("button\button"), action.x, action.y) then

... some statement


I am sorry to say this but actually,…it makes me confuse and i don’t know what to do…so i really need someone to explain me on how to use it and give me some good advice on how to fix this current problem that i had encountered…



Tip: If you put your code blocks inside two sets of three back-ticks, Discourse will automatically syntax hightight. So:

local my_var = “hello"”#", “a_message”)


local my_var = "hello""#", "a_message")


@sicher Thanks for the tip!..i already used it!.. :’)

1 Like


I’m sorry for not responding sooner. Did you solve this? If not, then try to isolate things down to a single guy and gui script.