I’m using the native keyboard to allow my user to associate a name with a high score.
There is a submit button on the screen associated with an event listener. When the user taps the submit button, the event listener looks for an “ended” event. When it receives an “ended” event, it adds the name and score to the high score table.
It seems to work fine in the simulator, but on an actual device, I get two ended events. Could this have something to do with the keyboard, since it isn’t on the simulator?
Here’s the listener code:
local function onUsername( event )
if ( "ended" == event.phase ) then
\>\> On a single button press on a device, I get here twice. \<\<
hs\_newname = highscoreName.text
if(game == EASY) then
-- submit scores to that scoreboard.
else
--
end
native.setKeyboardFocus( nil )
for i = highscoreScreen.numChildren, 1, -1 do
local child = highscoreScreen[i]
child.parent:remove( child )
end
highscoreName.isVisible = false
highscoreScreen.isVisible = false
button\_enterScore:removeEventListener("touch", onUsername)
return true
end
end
Any ideas on how I get rid of this problem?
Thanks,
Sean.
[import]uid: 4993 topic_id: 614 reply_id: 300614[/import]