Hello there,
I have noticed some odd things happening with my app when I test it on my HTC device. On my iPhone everything works just like it is meant to, but on the Android I have an issue…
I have two newTextFields on my screen. Each one is controlled by its own keyboardHandler, and has its own function for verification of the data entered. When the background is tapped and the keyboard is removed, focus appears to be moved automatically to the other newTextField (because the cursor flashes in it). Repeated tapping of the background causes the cursor to jump between the two newTextFields, and the event.phase == “ended” is called each time.
Is this normal behavior, because it does not happen on the iPhone?
Why is the cursor not removed completely from all newTextFields when the keyboard is dismissed?
I have isolated the bit of code causing the problem (into its own lua file) & include it below.
[lua]local nIPHeight = 72
local nIPFontSize = 24
local sSoundBoing = audio.loadSound(“snd_boing.wav”)
local sSoundBomb = audio.loadSound(“snd_bomb.wav”)
local nID = 0
– verification routines
local fVerifyWS = function()
audio.play(sSoundBoing)
end
local fVerifyWD = function()
audio.play(sSoundBomb)
end
– Keyboard Handlers
local fKeyboardTxtWS = function( event )
if ( event.phase == “began” ) then
nID = 1
elseif ( event.phase == “ended” ) then
nID = 11
fVerifyWS()
elseif ( event.phase == “submitted” ) then
– nothing done here as using a “Number” keyboard
nID = 111
end
end
local fKeyboardTxtWD = function( event )
if ( event.phase == “began” ) then
nID = 2
elseif ( event.phase == “ended” ) then
nID = 22
fVerifyWD()
elseif ( event.phase == “submitted” ) then
– nothing done here as using a “Number” keyboard
nID = 222
end
end
– input text fields
local txtWS = native.newTextField(10, 80, 140, nIPHeight, fKeyboardTxtWS)
txtWS.font = native.newFont(native.systemFontBold, nIPFontSize)
txtWS.align = “center”
txtWS.inputType = “number”
local txtWD = native.newTextField(170, 80, 140, nIPHeight, fKeyboardTxtWD)
txtWD.font = native.newFont(native.systemFontBold, nIPFontSize)
txtWD.align = “center”
txtWD.inputType = “number”
local lblTest = display.newText("-", 160, 50, native.systemFont, 16)
– Background to dismiss the keyboard
local bkgd = display.newRect(0, 0, 320, 480)
bkgd:setFillColor(0, 0, 0, 0)
– for removal of Keyboard
local fBkgdTap = function(event)
lblTest.text = nID
native.setKeyboardFocus(nil)
end
bkgd:addEventListener(“tap”, fBkgdTap)[/lua]
In my main app (using Director), when I dismiss the keyboard on one screen and move to another screen that also has newTextFields the cursor is in one of them already!
Does anyone have have any ideas? [import]uid: 74250 topic_id: 16784 reply_id: 316784[/import]