Text input question (SOLVED)

While getting input from user it is not possible to use “backspace” on android.
for example:

	if action_id == hash("text_input") then
		local node = gui.get_node("text")
	        local text = gui.get_text(node)
	        text = text .. action.text
	        gui.set_text(node, text)
	end

It works well, but if user make a mistake and trying to delete last symbol using a ‘backspace’, nothing happends. What can i do with this?

1 Like

I just did this myself, though for desktop. It’s very simple to remove the last character of a string.

local text = "blah de blah"
if action_id == hash("backspace") then
    	if action.pressed or action.repeated then
    		text = string.sub(text, 1, -2)
    		gui.set_text(node, text)
    	end
end

I don’t know how a “backspace” action would be set up on a phone though.

3 Likes

Oh!!! Thank you! It works for android as well.

2 Likes