Skip to end of metadata
Go to start of metadata

The following summarizes how to transition from the older Roku API to Scene Graph applications. In general, Scene Graph handles events without requiring you to write custom event loops, and allows you easily add custom event handlers by observing virtually any of the fields used in your Scene Graph application. Also, Scene Graph supplies built-in node classes that are very similar to some BrightScript UI screen components, but also gives you much greater flexibility to build your own custom screens. Because Scene Graph is more dynamic, flexible, and object-oriented than the older Roku API for building UI elements, you cannot write an equivalent Scene Graph application by simply substituting different function names and argument lists for UI elements.

However, much of your existing BrightScript code that handles other aspects of your application can probably be used in the new context of a Scene Graph application. For example, calls to your existing BrightScript functions can be added to any Scene Graph XML component file, by specifying the location of the BrightScript file in the package components directory in the <script> element. For example, if you had a set of functions to manipulate URLs, you could add the following <script> element to allow a Scene Graph component to call the functions:

<script type = "text/brightscript" uri = "pkg:/components/uriutils.brs" />

If these calls relied on application global data, you would have to set up a global node as described in Global Scope for this data.

There is a simplifying assumption you can make when transitioning an older Roku API application to Scene Graph. In many cases, Scene Graph replaces a series of BrightScript component interface function calls with setting and reading of node class fields of the equivalent parameters. For example, the SetNumPinEntryFields() interface function call for the roPinEntryDialog component is replaced by setting the pinLength field of the internal PinPad node object of a PinDialog node. But note that for many of the older Roku API screen components, you must develop your own custom screen component equivalent from more fundamental Scene Graph node classes. For example, you must develop an equivalent of the roSearchScreen component using the MiniKeyboard node class as the user input basis of a custom Scene Graph search screen component. You must then write additional BrightScript code to replicate the function of the roSearchScreen component.

BrightScript
Component
Scene Graph
Equivalent
Implementation
Notes 
roUniversalControlEventonKeyEvent()Scene Graph supplies a single function that replaces the need to write a remote control input event handling loop.
roTimespanTimer nodeAdding a Timer node, observing the fire field, and writing an event handler that scripts some aspect of another node is the equivalent of writing a loop including roTimespan.
BrightScript Component EventsScene Graph eventsYou can observe changes in virtually all aspects of Scene Graph operation using the <interface> field onChange attribute event, or adding an observer to a field of a Scene Graph node. 
roPinEntryDialogPinDialog nodeThe function of the PinDialog node is almost identical to the roPinEntryDialog component.
roTextScreenScrollableText nodeThese two are very similar in appearance and operation.
roFont, roFontRegistryFont nodeThe Font node simplifies specifying different fonts.
roGridScreenPosterGrid, MarkupGrid, RowList nodesThe built-in Scene Graph poster grid node classes are simpler, but much more flexible. You can use Scene Graph to create a custom grid screen identical to the older Roku API, but even better, you can create a completely original grid screen of your own design.
roImageCanvas, roScreenScene GraphScene Graph starts with the ability to draw your own custom screen elements, then use them as objects throughout your application.
roKeyboardScreenMiniKeyboard, Keyboard nodesThe keyboard screens and Scene Graph keyboard node classes are very similar in appearance and operation.
roListScreenLabelList, MarkupList, RowList, CheckList, RadioButtonList nodesScene Graph gives you many more options and flexibility for list screens.
roAudioPlayerAudio nodeThe roSpringboardScreen component for user selection of audio files can be created using Scene Graph list and grid node classes.
roVideoScreen, roVideoPlayerVideo nodeThe Scene Graph Video node class encompasses all the functionality of the roVideoScreen and roVideoPlayer components. The roSpringboardScreen component for user selection of video files can be created using Scene Graph list and grid node classes.
roSearchScreenMiniKeyboard nodeThe MiniKeyboard node class can be used as the user input basis of a custom Scene Graph component equivalent to the roSearchScreen component.
roSpringboardScreenScene GraphThe roSpringboardScreen component for user selection of audio/video files can be created using Scene Graph list and grid node classes.
  • No labels