I have three native textfields.
I want the Keyboard to set Focus on the next field after storing the storyboard variable if the character count is 4, but on the last then I want to perform a check and if that check matches then change screen.
I’m a bit stuck atm, how do I solve this problem?
if string.len(textField1) == 4 then save the value as storyboard.textValue1 then set focus on textField2. check and save this value as storyboard.textValue2 then set focus on textField3. check and save as storyboard.textValue3, now call checkText().
[code]
function fieldListener(textField)
return function( event )
if ( “began” == event.phase ) then
– This is the “keyboard has appeared” event
– In some cases you may want to adjust the interface when the keyboard appears.
elseif ( “ended” == event.phase ) then
– This event is called when the user stops editing a field: for example, when they touch a different field
elseif ( “editing” == event.phase ) then
elseif ( “submitted” == event.phase ) then
– This event occurs when the user presses the “return” key (if available) on the onscreen keyboard
print( textField().text )
– Hide keyboard
native.setKeyboardFocus( nil )
end
end
end
textField1:addEventListener( “userInput”, fieldListener( function() if string.len(textField.text) == 4 then storyboard.textValue1 = textField1.text native.setKeyboardFocus(textField2) end return textField1 end ) )
textField2:addEventListener( “userInput”, fieldListener( function() if string.len(textField.text) == 4 then storyboard.textValue2 = textField2.text native.setKeyboardFocus(textField3) end return textField2 end ) )
textField3:addEventListener( “userInput”, fieldListener( function() if string.len(textField.text) == 4 then storyboard.textValue3 = textField3.text native.setKeyboardFocus(nil) checkText() end return textField3 end ) )
[/code] [import]uid: 65840 topic_id: 35409 reply_id: 335409[/import]