Views are full-screen SceneGraph Developer Extension components that can be used as a template to build a view instead of creating one from scratch. SceneGraph Developer Extensions (SGDEX) supports out of the box stacking of the views. This means that you can add as many views to a stack as you want, and SGDEX will handle back button closing function of the view as well as add support for events when the view is:
- Hidden because next view is displayed
- Manually closed
ViewStack is designed to work with any Roku SceneGraph (RSG) component or a SGDEX view.
View stack handles basic focus when the view is opened or restores focus when it's closed.
According to Roku best practices, a view should handle focus by itself.
ViewStack sets focus to view by implementing
The view implements focus handling as follows:
Don't set focus to the view before adding it to
ViewStack as it sets focus to a previous view.
Note: Dialogs are not supported by ViewStack, use scene.dialog field instead.
Opening a new view
To add (open) a new view to the stack, use:
Receiving an event when the view is closed
If you want to be notified when the view is closed either manually or when the user has pressed back (
wasClosed), use the following:
Closing a view manually
To close a view manually, use the close field of view. This is useful when the channel needs to show the login flow after a successful login.
Note: Close field is added by
The developer can close any view in the stack, even if it is not on the top.
Using the component controller assists with implementing as well as managing the view stack. It essentially implements the basic default view management. Component Controller has fields to enable view development for building a channel using SceneGraph Developer Extensions. Refer to ComponentController Component for more details.
Component Controller Fields
currentView- Links to the view that is currently shown by ViewStack (This view represents the view that is shown by ViewStack. If another view without using ViewStack is shown, it wouldn't be reflected here)
allowCloseChannelOnLastView -If true, the channel closes when the back button is pressed or if the previous view set the view's close field to true
allowCloseLastViewOnBack- If true, the current view is closed, and the user can open another view through the new view's