Ok so I am trying to have quite a few input text fields in one gui file. but when I type into one of them it copies the values I sent into one of them into the other ones and when I remove it does the same to the others as well.
I followed a tutorial on text input but It was meant for just one input field.
How could I make two or more fields or really as many as I need without effecting each other?
this is my current input function
I am aware that I am using the same self.message and that is why it is effecting both of them. but how can I make separate messages for each field?
function on_input(self, action_id, action)
if(action_id == hash("click")and action.released == true)then
local loginBtn = gui.get_node("loginBtn")
local userField = gui.get_node("userBg")
local passField = gui.get_node("passBg")
local userTxt = gui.get_text(userField)
local passTxt = gui.get_text(passField)
if(gui.pick_node(loginBtn, action.x, action.y))then
print("i clicked log in")
end
if(gui.pick_node(userField, action.x, action.y))then
userFieldSel = true
passFieldSel = false
end
if(gui.pick_node(passField, action.x, action.y))then
passFieldSel = true
userFieldSel = false
end
end
if(userFieldSel == true)then
if action_id == hash("type") then
local userField = gui.get_node("userField")
local userTxt = gui.get_text(userField)
self.message = self.message .. action.text
gui.set_text(userField, self.message)
elseif action_id == hash("backspace") and action.repeated then
local l = string.len(self.message)
self.message = string.sub(self.message, 0, l-1)
label.set_text(userField, self.message)
end
end
if(passFieldSel == true)then
if action_id == hash("type") then
local passField = gui.get_node("passField")
local passTxt = gui.get_text(passField)
self.message = self.message .. action.text
gui.set_text(passField, self.message)
elseif action_id == hash("backspace") and action.repeated then
local l = string.len(self.message)
self.message = string.sub(self.message, 0, l-1)
gui.set_text(passField, self.message)
end
end
end