Roku Developer Program

Join our online forum to talk to Roku developers and fellow channel creators. Ask questions, share tips with the community, and find helpful resources.
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
btpoole
Channel Surfer

OnKeyEvent Loop?

Having a problem that makes no sense, well not to me.  I start out with a preview video component  set up in the corner of the screen. A video is selected and started, if the user presses the star button the screen is suppose to go full screen. This works but the screen goes from preview to full screen back to preview almost like it's in a loop. My onkeyevent is

function onKeyEvent(key as String, press as Boolean) as Boolean
    handled = false
    if (m.simpleMarkupList.hasFocus() = true) and (key = "right") and (press=true)
   m.simpleMarkupGrid.setFocus(true)
  m.simpleMarkupList.setFocus(false)
           m.simpleMarkupGrid.horizFocusAnimationStyle="floatingFocus"
           m.top.Description.visible=true
           ?"key "key
   handled = true
  else if (m.simpleMarkupGrid.hasFocus() = true) and (key = "left") and (press=true)
  m.simpleMarkupGrid.setFocus(false)
  m.simpleMarkupList.setFocus(true)
           m.top.Description.visible=false
    handled = true
  else if (m.video.hasfocus()=true) and (key="options")
     ?"key "key
     screenchange()
     handled= true
end if
    return handled
end function


The code for the screenchange() follows
sub screenchange()
if m.video.width=300
    m.video.width="1280"
    m.video.height="720"
    m.video.translation="[0,0]"
    ?"CURRENT SCREEN IS NOW FULL"
else
    m.video.width="300"
    m.video.height="150"
    m.video.translation="[400,70]"
     ?"CURRENT SCREEN IS NOW SMALL"
end if
end sub

Once the video starts initially in small screen and the star is press it does go to screenchange, changes to full screen but right back to small screen. Seems like it skips the else in the if statement. Am I overlooking something simple?
Thanks
0 Kudos
2 REPLIES 2
belltown
Roku Guru

Re: OnKeyEvent Loop?

Looks like you're missing: 
and (press=true)


so screenchange() will fire on both the options key press and the release.
0 Kudos
btpoole
Channel Surfer

Re: OnKeyEvent Loop?

Thank you belltown that did it.
0 Kudos