I am working with Scenegraph Developer Extension (SGDEX) for developing one login flow.
Now when I press Ok button in textBox the keyboard is appearing ,
But what I want is when I press backButton (once) the keyboard should disapper and if I press backButton again my screen should navigate to previous screen,
You've posted to a forum for Roku users, where few, if any, will be able to help. The Developers forums are here: https://community.roku.com/t5/Developers/ct-p/channel-developers
function onKeyEvent(key as string, press as boolean) as boolean
handled = false
if press then
if(key = "back")
if (m.keyboard.visible)
m.keyboard.visible = false
' only return true when you want to swallow the keypress
' we want to swallow the keypress only when keyboard is visible and back is pressed
handled = true
end if
end if
end if
return handled
end function
... or even shorter version ...
function onKeyEvent(key as string, press as boolean) as boolean
handled = false
if press and (key = "back") and (m.keyboard.visible)
m.keyboard.visible = false
' only return true when you want to swallow the keypress
' we want to swallow the keypress only when keyboard is visible and back is pressed
handled = true
end if
return handled
end function
You almost had it. You just forgot to only swallow the keypress at the right time part. You don't want to return true every time the back button is pressed which is what your code block did. You only want to swallow the keypress (aka return true) when you have a visible keyboard.
When the OnKeyEvent returns false it allows the keypress to pass upwards to the other components in the extend/scene.