Roku Developer Program

Developers and content creators—a complete solution for growing an audience directly.
cancel
Showing results for 
Search instead for 
Did you mean: 
vrihlea
Level 7

base library bslCore.brs

https://sdkdocs.roku.com/display/sdkdoc/Component+Architecture#ComponentArchitecture-v30/bslCore.brs

there are two methods in there that caught my attention:
- bslBrightScriptErrorCodes()
- bslUniversalControlEventCodes()[/font][/color]

a) Is there a way to get the button-press event before it gets to the "onKeyEvent()" in the component ?
one usecase for this would be to disable the quick-play (or the remote) so that it won't be possible to press it multiple times

b)
   screen = CreateObject("roSGScreen")
   m.port = CreateObject("roMessagePort")
   screen.setMessagePort(m.port)
   ' ...
   while(true)
       msg = wait(0, m.port)
       ' the roku-remote events are not handled here so what's the point in bslUniversalControlEventCodes()


what would be a possible use-case for bslBrightScriptErrorCodes() ?[/font][/color]
0 Kudos
5 Replies
Roku Employee
Roku Employee

Re: base library bslCore.brs

"vrihlea" wrote:
a) Is there a way to get the button-press event before it gets to the "onKeyEvent()" in the component ?
one use case for this would be to disable the quick-play (or the remote) so that it won't be possible to press it multiple times

Yes - by temporarily setting the input focus on another node (regardless whether parent or sibling of the current one) and handling it there. Or not handling it (with chance of beep or exit). The point is, excluding the component at hand from the key event handling chain
0 Kudos
belltown
Level 7

Re: base library bslCore.brs

"vrihlea" wrote:
b)
what would be a possible use-case for bslUniversalControlEventCodes() and bslBrightScriptErrorCodes() ?


bslUniversalControlEventCodes() could be used in a 2D API application, which uses an roUniversalControlEvent to convey key press information: https://sdkdocs.roku.com/display/sdkdoc/Runtime+Functions#RuntimeFunctions-Eval(codeasString)asDynam...
https://github.com/belltown/
0 Kudos
vrihlea
Level 7

Re: base library bslCore.brs

"RokuNB" wrote:
"vrihlea" wrote:
a) Is there a way to get the button-press event before it gets to the "onKeyEvent()" in the component ?
one use case for this would be to disable the quick-play (or the remote) so that it won't be possible to press it multiple times

Yes - by temporarily setting the input focus on another node (regardless whether parent or sibling of the current one) and handling it there. Or not handling it (with chance of beep or exit). The point is, excluding the component at hand from the key event handling chain

yes I could "unfocus" the current element but the "onKeyEvent" on the "parent component" (the element that I'm focussing) would still get called, is there a way to avoid that ?
I would like to either focus the same "global" node/component from everywhere or find a way to use bslUniversalControlEventCodes()[/font]
I'm trying to figure out how to use bslUniversalControlEventCodes() based on this topic: https://forums.roku.com/viewtopic.php?f=34&t=99328&p=551386&hilit=roUniversalControlEvent#p551386

    screen = CreateObject("roSGScreen")
   ' m.port = CreateObject("roMessagePort")
   m.port = CreateObject("roUniversalControlEvent")
   screen.setMessagePort(m.port)

   while true
       msg = wait(0, screen.GetMessagePort())
       if type(msg) = "roPosterScreenEvent"
           if msg.isRemoteKeyPressed()
               stop
           end if
       end if

it never gets to the "stop", did I miss something ?
0 Kudos
Roku Employee
Roku Employee

Re: base library bslCore.brs

"vrihlea" wrote:

    screen = CreateObject("roSGScreen")
   ' m.port = CreateObject("roMessagePort")
   m.port = CreateObject("roUniversalControlEvent")
   screen.setMessagePort(m.port)

   while true
       msg = wait(0, screen.GetMessagePort())
       if type(msg) = "roPosterScreenEvent"
           if msg.isRemoteKeyPressed()
               stop
           end if
       end if

it never gets to the "stop", did I miss something ?


The only object that can be used with SetMessagePort is an roMessagePort.
Trying to use an roUniversalControlEvent object as a message port won't do anything.

I guess your intent might have been to receive roUniversalControlEvents,
where you are checking for "roPosterScreenEvent", but that also won't help,
as roUniversalControlEvents are only generated by an roScreen screen, not by
an roSGScreen.

Hope that helps.
0 Kudos
vrihlea
Level 7

Re: base library bslCore.brs

so "roSGScreen" works with components (lists, grids ...) and "roScreen" is used for drawing and stuff.

but is there a way to make something like a global-onKeyEvent ?
meaning before a key-press event gets to onKeyEvent in a component it should first go through main()[/color]
0 Kudos