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: 
renojim
Level 8

ButtonGroup never hasFocus

I'm still trying to wrap my head around this roSG stuff. I noticed that if I have a CheckList and a ButtonGroup within a scene I can use setFocus() to switch between them, but calling hasFocus() on the ButtonGroup always returns false (even when a button has the focus). This seems wrong to me. Calling hasFocus() on the CheckList works as expected. It isn't keeping me from doing anything; it just bugs me. Am I missing something fundamental about scenes and components?

-JT
0 Kudos
3 Replies
joetesta
Level 10

Re: ButtonGroup never hasFocus

Yeah it is confusing.  Apparently only one node can have focus at a time, and according to the button group doc, "When the ButtonGroup node has focus, it sets the key focus on a single one of its child Button nodes."
https://sdkdocs.roku.com/display/sdkdoc/ButtonGroup

So once that child button node has focus, the group no longer does.  In this case you can use isInFocusChain() to determine whether the group has focus.
https://sdkdocs.roku.com/display/sdkdoc/ifSGNodeFocus#ifSGNodeFocus-isInFocusChain()asBoolean
aspiring
0 Kudos
renojim
Level 8

Re: ButtonGroup never hasFocus

Thanks! I really need to read the docs more, but I'd rather slog through and just get my channels converted. Maybe I'll read later. Smiley LOL It just seems to me that a node should hasFocus() if any of its children does, but I guess there may be something to be said for only one node being able to have focus at a time.

-JT
0 Kudos
joetesta
Level 10

Re: ButtonGroup never hasFocus

well I learned this stuff the hard way and just reference the docs to back up what I think I know Smiley Happy
But I agree, took me a while to understand that only one node can have focus and this sort of immediate off-loading of focus to a subcomponent means the parent never has focus even if you assign it directly.
aspiring
0 Kudos