Skip to main content

Custom panels

Your channel can add a panel of its own to the SDK's tab strip. Build the panel as a SceneGraph component that extends the published MaestroCustomPanel base, create it, and hand it to the SDK with addPanelToEvent. The SDK then treats it as one of its own panels: a tab with your title and icon, the event and player clock pushed to it, focus and keys routed normally, panel view / engage / card-focus analytics beacons, and survival across config reloads.

Setup​

  1. Copy the SDK's published MaestroCustomPanel folder into your channel (for example, components/maestro/MaestroCustomPanel/). The folder will be in the example repo (maestro-roku-sdk-example) once it ships. Don't edit the copy: copy it again to update.
  2. Create a SceneGraph component that extends="MaestroCustomPanel".
  3. Call addPanelToEvent on the MaestroPanel node.
<component name="MyStatsPanel" extends="MaestroCustomPanel">
<script type="text/brightscript" uri="MyStatsPanel.brs" />
<children>
<Label id="heading" translation="[40, 24]" />
<LabelList id="rows" translation="[40, 120]" itemSize="[640, 56]" />
</children>
</component>
sub init()
m.top.panelType = "myStats" ' unique key (letters, digits, _)
m.top.title = "My Stats" ' tab label
m.top.iconUri = "pkg:/images/myStatsNavIcon.png" ' tab icon (36 × 36)
m.top.order = 0 ' 0 = first tab; -1 = after the SDK's tabs
m.rows = m.top.findNode("rows")
m.rows.observeFieldScoped("itemFocused", "onRowFocused")
m.rows.observeFieldScoped("itemSelected", "onRowSelected")
end sub

' Called by the SDK each time the tab gets focus: fetch once per event
sub getData(params = invalid as dynamic)
if m.loadedEventId = m.top.eventID then return
m.loadedEventId = m.top.eventID
' fetch for m.top.eventID, then draw
end sub

' Focus came in from the tab bar
sub onFocusEntered()
m.rows.setFocus(true)
end sub

sub onRowFocused(event as object)
emitCardFocus("statRow", event.getData())
end sub

sub onRowSelected(event as object)
emitEngage("select", "statRow")
end sub

' Return false for keys the panel does not handle: the SDK moves focus to the tab bar
function onKeyEvent(key as string, press as boolean) as boolean
if press and key = "up" and m.rows.itemFocused = 0
clearCardFocus()
requestFocusReturn()
return true
end if
return false
end function

Then add the panel from your channel's Maestro script, before or after the SDK's config loads:

' Maestro.brs: call once m.maestro exists (Getting Started, step 2)
sub addMyStatsPanel()
panel = createObject("roSGNode", "MyStatsPanel")
accepted = m.maestro.callFunc("addPanelToEvent", {
node: panel
panelType: panel.panelType ' "myStats"
title: panel.title ' "My Stats"
iconUri: panel.callFunc("stagedIconUri") ' see Icons below
order: panel.order ' 0
})
if not accepted then print "Custom panel rejected: "; m.maestro.errorInformation.message
end sub

Spec fields​

FieldRequiredDescription
nodeyesThe panel node. Must extend MaestroCustomPanel (the SDK checks for a panelType field).
panelTypeyesUnique identifier: letters, digits and _ only. Used as the node's id, the tab key, and the analytics type. See the reserved types below.
titleyesThe tab label. Also the analytics panel name (e4).
iconUrinoThe tab icon URI. A pkg:/ path must be staged with stagedIconUri() first (see Icons). Without one, the SDK's fallback tab icon shows.
ordernoTab position: 0 is first, the SDK's tabs shift right. Equal orders keep the insertion order. -1 or past the end goes last. Defaults to -1.

addPanelToEvent returns true when the panel was accepted. A rejection is logged as addPanelToEvent rejected - <reason> and reported on errorInformation as { message, panelType }. Reasons:

  • The spec isn't an associative array, or has no node.
  • The node has no panelType field (it doesn't extend MaestroCustomPanel).
  • panelType is missing, or has characters other than letters, digits and _.
  • panelType is a type the SDK builds itself: HelloWorld, EmptyView, or a panel type in the page config.
  • panelType is reserved: a name the MaestroPanel node already uses internally (for example scene or overlays). Pick a distinctive type.
  • title is missing, or order isn't a number.

removePanelFromEvent(panelType) removes the panel and its tab. Returns false for an unknown panel type.

Panel contract​

The base declares all fields the SDK reads and writes. Override the named functions in your subclass.

DirectionField / functionWhat
Your init sets, SDK readspanelType, title, iconUri, orderTab and analytics identity. The spec's values override the node's own.
SDK writesid, panelTypeBoth set to the spec's panelType.
SDK writesname, client, clientConfig, displayQRCodesAs the SDK sets its own panels. name is the title.
SDK writeseventIDThe page config's first event, or the session's; "" on a multi-event page. Re-sent on every rebuild.
SDK writestimeCodePlayer position as epoch ms string, floored to 500 ms; "" before the first tick.
SDK writesvisibleFollows the tab, like any panel.
SDK callsgetData()Each time the tab gets focus, and again when the tab strip is rebuilt. Also at build time when fetchDataOnInit is true. Make it safe to call repeatedly.
SDK callsendSession()When the session ends. An override must call mcpEndSession() to stop managed timers.
OverrideonEventIdChanged(eventId)A new event (stream switch).
OverrideonTimeCodeChanged(timeCode)The player moved (at most twice a second).
OverrideonFocusEntered()Focus entered from the tab bar: move focus to your first control.
OverrideonKeyEvent(key, press) → booleanReturn false for keys the panel does not handle. See Focus and keys.
CallemitEngage(action, target, metadata?)Sends an engage beacon (e5 = action, e6 = target).
CallemitCardFocus(card, index, list?)Sends a card-focus beacon after 300 ms of dwell.
CallclearCardFocus()Cancels any pending card-focus beacon.
CallrequestFocusReturn()Returns focus to the SDK's tab bar, or to your channel in single-tab mode.
CallmcpTimer(seconds, callbackName, repeat?)A timer that endSession stops automatically.
CallshowError(title, subTitle?, iconUri?, width?, height?)Shows the SDK's error view in the panel's place.
CallreloadPanel()Clears the error view and calls getData again.
CallstagedIconUri()Returns the icon URI suitable for passing to addPanelToEvent (see Icons).
CallstagedUri(uri)Returns any pkg:/ URI copied to tmp:/, where the SDK can load it.

A setDataToPanel write for your panel type (before or after the add) is applied field by field and re-applied on every rebuild. Only fields the node declares are written on a rebuild.

userSettings hide_panel applies to a host panel: it gets no tab.

Focus and keys​

  • Down from the tab bar enters the panel and calls onFocusEntered().
  • A key your onKeyEvent returns false for goes to the SDK. Back, Up and Left move focus to the tab bar (Left goes to the overlay when one is on screen). A short OK stays in the panel.
  • Holding OK to close the drawer works only in builds that enable the long press (Paramount today).
  • Single-tab mode: with hidePanelSelector: true in config and a host panel as the only tab, there is no tab bar. Back from the panel bubbles to your scene. requestFocusReturn(), or removing the panel while it has focus, sets the MaestroPanel field handleLoadingSceneAction to "returnFocus". Observe it in createMaestroPanel() with observeFieldScoped and take focus back:
sub onMaestroHandleLoadingSceneAction(event as object)
if event.getData() = "returnFocus" then m.maestro.showPanel = false ' the showPanel observer moves focus
end sub

Lifecycle​

  • Before the config lands: the spec is kept and the panel is mounted on the next build, which also sends rendered:channels with the panel listed.
  • After the config lands: the panel is mounted immediately, the tab strip is rebuilt, and rendered:channels is sent again. panelsBuilt is not set again. The rebuild re-focuses the current tab: that tab's panel gets getData() again, and userViewedPanel and a panel view follow.
  • Debug panel: a host panel counts as a supported panel, so it replaces the HelloWorld debug panel shown with useProdEnv: false.
  • Same panelType added again: the same node updates its metadata; a different node replaces it. If the viewer was inside the panel being replaced, focus returns to the tab bar first.
  • Config reload, userSettings rebuild or userDidStartWatchingEvent: host panels are kept across rebuilds and have their event fields re-applied.
  • SDK panel with the same type: a configured SDK panel whose type matches a host panel is skipped. The host panel wins.
  • removePanelFromEvent: endSession is called, the node is detached, the tab is removed, and rendered:channels is sent. If the viewer was inside the panel, focus returns to the tab bar first (single-tab mode: see Focus and keys).
  • destroySDK: all host panels are ended and detached. After restartSDK, add them again.
  • Single-tab mode (hidePanelSelector: true with one tab): adding a host panel to a page with one SDK panel makes two tabs; the tab bar appears and the panels move back under it.

Icons​

The SDK draws the tab icon from inside its component library, where your channel's pkg:/ path does not resolve. Stage the icon before calling addPanelToEvent: pass panel.callFunc("stagedIconUri") as the spec's iconUri.

stagedIconUri() copies a pkg:/ icon to tmp:/maestroCustomPanel_<panelType>_<filename> and returns that path. http(s):// and tmp:/ URIs pass through unchanged. Call it after iconUri and panelType are set on the node.

For error view icons, use stagedUri(uri) (it accepts any URI, not just the icon field).

Analytics​

The panel's panelType is its analytics e2_class and e3_order; its title is e4_family. Because the SDK cannot name host panel types in advance, they use the same generic builders as designed panels (panelViewDesigned / panelEngageDesigned).

  • View: sent on the 1-second focus debounce, as a generic view event.
  • Engage: call emitEngage(action, target) from your panel code. The SDK builds the beacon from the panelEngage field and drops an engage without an action. A variant or panel key in the metadata is ignored.
  • Card focus: call emitCardFocus(card, index) when a list item gets focus; call clearCardFocus() when focus leaves the list.

Your channel receives the beacons on trackAction and trackImpression like any other panel.

Rules​

  • mcp prefix is reserved. The base's scripts and yours share one scope (as every SceneGraph parent and child do). A function named the same as one in the base replaces it. Override only the plain-named functions above (getData, onFocusEntered, etc.).
  • An endSession override must call mcpEndSession(), or the base's managed timers keep running.
  • id is overwritten with panelType by the SDK. Do not rely on the node's initial id.
  • Multi-event pages pass "" for eventID: there is no single event to fetch for.
  • Keep the base plain BrightScript. The published folder uses no BrighterScript features (import, namespace, template strings) so it compiles as-is in any channel.