hi guys.
I am creating a storyboard, which calls a overlay.
In that overlay, I have a “newTextField” for the user to input text.
There is a Submit button in the overlay (see code below)
My issue is that, when i build the debug apk for Android and test it on a real device (tried building the apk on Windows & Mac), the Submit button does not work (it just closes the keyboard without any “event.phase = ended” triggered ). But if I close the keyboard manually, the “event.phase = ended/submit” gets triggered.
I tried the submit button on a Mac simulator, and it works (“event.phase = ended” triggered)
Please advise.
Thanks
– Show editable text
local fieldHandler = function( event )
print( event.phase )
if “began” == event.phase then
elseif “ended” == event.phase then
– Return the keyed-in text, using “event.target.text”
keyedInText = event.target.text
titleTextObj.text = keyedInText
storyboard.hideOverlay( false )
print(keyedInText)
elseif “submitted” == event.phase then
keyedInText = event.target.text
titleTextObj.text = keyedInText
storyboard.hideOverlay( false )
print(keyedInText)
end
end
local inputBox
if isAndroid then
inputBox = native.newTextField( 50, 150, 220, 45, fieldHandler ) – Bigger box for Android
else
inputBox = native.newTextField( 50, 150, 220, 35, fieldHandler )
end
inputBox.isEditable = true
inputBox.hasBackground = true
inputBox:setReferencePoint(display.CenterReferencePoint);
inputBox.x = display.contentCenterX
inputBox.y = display.contentCenterY
Display.group:insert(inputBox)
– Show button to close keyboard (to activate “submit” state for textField)
– local submitButtonPressEvent = function( event )
local function submitButtonPressEvent( event )
local phase = event.phase
print("dialogBoxHandling submitButtonPressEvent() : " … phase)
if “ended” == phase then
native.setKeyboardFocus( nil )
storyboard.hideOverlay( false )
end
end
local submitButton = widget.newButton
{
left = 0,
top = 0,
width = 100,
height = 50,
label = “Submit”,
labelAlign = “center”,
font = “Arial”,
fontSize = 18,
labelColor = { default = {0,0,0}, over = {255,255,255} },
onEvent = submitButtonPressEvent
}
submitButton:setReferencePoint(display.CenterReferencePoint);
submitButton.x = display.contentCenterX
submitButton.y = display.contentCenterY + 50
Display.group:insert(submitButton)