I set press value in onkeyevent function. But value by default false and It's press then set press value is true. I created two button in one screen and I set Button value to maintain Focus Correctly. I set active value true and open dialog box and maintain focus with dialog button but Its set to dialog button and screen button both the focus work together. Does anyone know how to separate the Both Press?
Here my code to set both the value
function onKeyEvent(key as String, press as Boolean) as Boolean
? "PanelSet :: Key Event is about to execute - key = "key " press = " press
' getConfig()
' ? "Display the XML Data: "m.gridpanel.grid.content.getChild(m.gridpanel.grid.itemFocused)
handled = false
? "here the focus available dialog focus "
if press = true then
if m.keyid.active = true and key = "OK" then
?"Email Ok Press"
showdialogid()
handled = true
else if m.keypass.active = true and key = "OK" then
?"Password Ok Press"
showdialogpass()
handled = true
end if
return handled
end if
if press = false then
? "here Login Screen Press available " press
' here the every time call if condition if enter the value on keyboard and keybord ok press to call textbox password active = true
if key = "up" or key = "down"
if key = "down"
?"here down key"
if m.keypass.active = true
m.keyid.active = false
m.keypass.active = false
m.btnsubmit.setFocus(true)
m.btnsubmit.focusBitmapUri = "pkg:/images/newsignin.png"
m.btnsubmit.iconUri=""
m.btnsubmit.focusedTextColor = "0x00000000"
handled = true
else if m.keyid.active = true
m.keyid.active = false
m.keypass.active = true
handled = true
else if m.btnsubmit.focusBitmapUri <> ""
? "setting active and key down press "
m.btnsubmit.focusBitmapUri = ""
m.btnsubmit.setFocus(false)
m.btnsetting.setFocus(true)
m.btnsetting.focusBitmapUri = "pkg:/images/newsetting.png"
m.btnsetting.focusedTextColor = "0x00000000"
handled = true
else if m.btnsetting.focusBitmapUri <> ""
? "id active and key down press"
m.btnsetting.focusBitmapUri = ""
m.btnsetting.setFocus(false)
m.keyid.setFocus(true)
m.keyid.active = true
handled = true
handled = true
end if
handled = true
else if key = "up"
? "here up key"
if m.keypass.active = true
?"id active and press up"
m.keypass.active = false
m.keyid.active = true
handled = true
else if m.keyid.active = true
?"setting active and press up"
m.keyid.active = false
m.btnsetting.setFocus(true)
m.btnsetting.focusBitmapUri = "pkg:/images/newsetting.png"
m.btnsetting.focusedTextColor = "0x00000000"
handled = true
else if m.btnsetting.focusBitmapUri <> ""
?"submit active and press up"
m.btnsetting.focusBitmapUri = ""
m.btnsetting.setFocus(false)
m.btnsubmit.setFocus(true)
m.btnsubmit.focusBitmapUri = "pkg:/images/newsignin.png"
m.btnsubmit.iconUri=""
m.btnsubmit.focusedTextColor = "0x00000000"
handled = true
else if m.btnsubmit.focusBitmapUri <> ""
? "pass active and press up"
'press = false
? "press value active : " press
m.btnsubmit.focusBitmapUri = ""
m.btnsubmit.setFocus(false)
m.keypass.setFocus(true)
m.keypass.active = true
handled = true
end if
handled = true
end if
handled = true
end if
if key = "OK" and m.btnsetting.focusBitmapUri <> ""
?"Click the sign in button"
handled = true
else if key = "OK" and m.btnsubmit.focusBitmapUri <> ""
handled = true
end if
return handled
end if
if press = true then
? "Video size incresed"
'Key handler for ok button press then store the url in xml file and use everywhere particular url
if key="options" then
'we are not in video playback
' If Not m.video.visible Then
if NOT m.dialog.visible then
? "video option menu is open"
' ShowKeyboardScreen()
showdialog()
m.dialog.visible = false
m.dialog.focusable = false
' if m.dialog.visible = true
' m.dialog.visible = false ' Here the close the keyboard dialog box
' end if
'Here the Code For the if ok button Press then dialog box close and load the channel
result = true
return true
else
? "video option menu is closed"
m.dialog.visible = false
m.dialog.setFocus(false)
m.top.videoplayer.setfocus = true
m.gridpanel.grid.content.setFocus = true
m.listpanel.list.content.setFocus = true
m.focusedNode.SetFocus(true)
result = true
return true
end if
end if
if key = "back"
? "Back pressed - nikunj = handled = " handled
if not m.video.state = "playing" then
handled = verifyexit()
? "Back pressed - jigar = handled = " handled
return handled'true
end if
handled = false
'video = m.top.videoPlayer.findNode("liveVideo")
? "Video state = " m.video.state
if (m.video.state = "playing")
?"set videoplayer focus"
m.video.control = "stop"
' m.ButtonGroup.setFocus(true)
m.video.visible = false
m.top.videoPlayer.visible = false
m.top.visible = true
m.top.setFocus(true)
m.panelset.setFocus(true)
m.gridpanel.setFocus(true)
handled = true
end if
'handled = true
return handled
end if
if key = "play"
list = []
color = "#80000000" 'semi-transparent black
' m.video.control = "pause"
if m.video.state = "playing"
? "video is paused"
'Here the paused label print on above video
list.Push({
Text: "Paused"
TextAttrs: { font: "huge" }
TargetRect: m.top.videoPlayer.Resolution
})
m.video.control = "pause"
m.top.visible = true
else
? "video is resumed"
m.video.control = "resume"
list.Push({
Text: "Paused"
TextAttrs: { font: "huge" }
TargetRect: m.top.videoPlayer.Resolution
})
end if
' m.canvas.SetLayer(1, list)
end if
m.progress = 0
m.position = 60
if key = "fastforward"
? "video fast forward"
m.video.control = "FastForward"
m.position = m.position + 60
end if
if key = "rewind"
? "video Rewind"
m.video.control = "Rewind"
m.position = m.position - 60
end if
if key = "replay"
m.gridpanel.visible = false
m.listpanel.visible = false
m.keypanel.setFocus(true)
return true
end if
if key = "up" or key = "down"
? "Up key is change the video channel and down key for again particular video displayed"
bUp = true
if key = "down" then
bUp = false
end if
if (m.video.state = "playing")
?"set videoplayer focus"
m.video.control = "stop"
m.gridpanel.setFocus(true)
?" m.gridpanel.content.getChildCount() = " m.gridpanel.grid.content.getChildCount()
nTotalItem = m.gridpanel.grid.content.getChildCount()
? " m.gridpanel.grid.itemFocused = " m.gridpanel.grid.itemFocused
if key = "up"
if m.gridpanel.grid.itemFocused = 0 then
m.gridpanel.grid.jumpToItem = nTotalItem - 1
? "arrow selected "
else
m.gridpanel.grid.jumpToItem = m.gridpanel.grid.itemFocused - 1
? "arrow selected "
end if
endif
if key = "down"
if m.gridpanel.grid.itemFocused = nTotalItem - 1 then
m.gridpanel.grid.jumpToItem = 0
? "arrow selected "
else
m.gridpanel.grid.jumpToItem = m.gridpanel.grid.itemFocused + 1
? "arrow selected "
end if
endif
? " m.gridpanel.grid.itemFocused = " m.gridpanel.grid.itemFocused
m.video.control = "Play"
m.top.videoPlayer.setFocus(true)
handled = true
end if
end if
end if
return handled
end function
You are coding for keypress = false. Most probably this will be the cause of your issue. Don't know what are your requirements, but its not a good practice to program on false 'keypress' events as 'false' events are generated when key is released. As per my observation for your code, I have some suggestions--
Set handled = false
as first line of onKeyEvent() function
Add return handled
as the last statement of onKeyEvent() function
Check if this solves your problem.
User contributions licensed under CC BY-SA 3.0