I want to use "Input" in "Dirty Larry GUI" (SOLVED)

I want to use “Input” in “Dirty Larry GUI”. But when I press the button after inputting, the text of “Input” is not initialized. I tried gui.set_text (“button / content”, “”) and the ‘console’ was initialized. But the text still remained on the screen. What should I do?

	self.input_title = dirtylarry:input("name1", action_id, action, gui.KEYBOARD_TYPE_DEFAULT, "Title")
	self.input_name = dirtylarry:input("name2", action_id, action, gui.KEYBOARD_TYPE_DEFAULT, "Name")
	
	dirtylarry:button("clearbutton", action_id, action, function()
		print("ClearBt")
		
		local nodes = gui.get_node("name1/content")		
		gui.set_text(nodes, "")
		local nodes = gui.get_node("name2/content")		
		gui.set_text(nodes, "")
	end)
1 Like

Hi @sungin.ji!

There isn’t an easy way to change/clear an input field, but there really should be! :slight_smile: Try adding this function below your require statement for dirtylarry;

local dirtylarry = require "dirtylarry.dirtylarry"

function dirtylarry.set_input(self, node, txt)
    local node_content = gui.get_node(node .. "/content")
    local url = msg.url()
    local key = tostring(url.socket) .. hash_to_hex(url.path) .. hash_to_hex(url.fragment or hash("")) .. node
    dirtylarry.input_nodes[key].data = txt
    gui.set_text(node_content, txt)
end

then in your button callback, call dirtylarry:set_input("name1", ""), something like this:

dirtylarry:button("clearbutton", action_id, action, function()
	print("ClearBt")
	dirtylarry:set_input("name1", "")
	dirtylarry:set_input("name2", "")
end)

Hope it helps!
I will evaluate if the set_input function should be added to the dirtylarry library as well.

4 Likes

Oh. That’s the answer I really wanted. It has helped a lot. Thank you

3 Likes