- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Is there a way to know what node had the last focus?
I don't know if this is possible, but is there a way to know what node had the last focus?
for example, if I have a poster, a rectangle, etc, and I open a dialog, but would want to setfocus to the last item that had focus before the dialog was opened. How do I go about it?
Thanks.


- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Re: Is there a way to know what node had the last focus?
Hi @dan19,
The roSGnode.ifSGNodeFocus interface does not support checking which node last had focus. The channel code should keep track of the item from which the dialog was opened. For example, if the poster or rectangle was in array, you would have the index of the last selected item.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Re: Is there a way to know what node had the last focus?
You can observe 'focusedChild' on any Node, that might help.
(Looking at my own code I have a lot of spaghetti around focus management so I don't recall exactly what the default behaviours are but if you're on the Roku UI happy path hopefully you won't need to lose too much hair.)
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Re: Is there a way to know what node had the last focus?
Thanks for taking the time to answer me. I have a dialog that is shown when the options key is pressed, and when the back key is pressed, the dialog closes. So I am trying to set focus to the last Item/node that was in focus before the options key was pressed. If there is no inbuilt method for this, what will be the best logic to tackle this?
Thanks.
@RokuJonathanD wrote:Hi @dan19,
The roSGnode.ifSGNodeFocus interface does not support checking which node last had focus. The channel code should keep track of the item from which the dialog was opened. For example, if the poster or rectangle was in array, you would have the index of the last selected item.