Your Digital Media Has Never Looked So Good

 
renojim
** Valued Community Member **
Topic Author
Posts: 3376
Joined: Mon Feb 15, 2010 1:35 pm

ButtonGroup never hasFocus

Thu Aug 09, 2018 10:43 am

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
 
joetesta
Posts: 771
Joined: Wed Apr 20, 2011 11:48 am

Re: ButtonGroup never hasFocus

Thu Aug 09, 2018 5:10 pm

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
 
renojim
** Valued Community Member **
Topic Author
Posts: 3376
Joined: Mon Feb 15, 2010 1:35 pm

Re: ButtonGroup never hasFocus

Thu Aug 09, 2018 8:43 pm

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. :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
 
joetesta
Posts: 771
Joined: Wed Apr 20, 2011 11:48 am

Re: ButtonGroup never hasFocus

Fri Aug 10, 2018 7:34 am

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

Who is online

Users browsing this forum: No registered users and 6 guests