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: 
renojim
Community Streaming Expert

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
Roku Community Streaming Expert

Help others find this answer and click "Accept as Solution."
If you appreciate my answer, maybe give me a Kudo.

I am not a Roku employee.
0 Kudos
3 REPLIES 3
joetesta
Roku Guru

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
Community Streaming Expert

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
Roku Community Streaming Expert

Help others find this answer and click "Accept as Solution."
If you appreciate my answer, maybe give me a Kudo.

I am not a Roku employee.
0 Kudos
joetesta
Roku Guru

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 🙂
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
Need Assistance?
Welcome to the Roku Community! Feel free to search our Community for answers or post your question to get help.

Become a Roku Streaming Expert!

Share your expertise, help fellow streamers, and unlock exclusive rewards as part of the Roku Community. Learn more.