addPanelToEvent()
Adds a host-built panel to the SDK's tab strip.
Syntax
accepted = m.maestro.callFunc("addPanelToEvent", {
node: panel
panelType: panel.panelType
title: panel.title
iconUri: panel.callFunc("stagedIconUri")
order: panel.order
})
Parameters
| Parameter | Type | Description |
|---|---|---|
node | roSGNode | The panel node. Must extend MaestroCustomPanel (the SDK checks for a panelType field). |
panelType | string | Unique identifier: letters, digits and _ only. Must not be a type the SDK builds (HelloWorld, EmptyView, a type in the page config) or a reserved name. Used as the node's id, the tab key, and the analytics type (e2). |
title | string | The tab label. Also the analytics panel name (e4). |
iconUri | string | (optional) The tab icon URI. Stage a pkg:/ path with stagedIconUri() first. |
order | integer | (optional) Tab position: 0 is first. -1 or past the end goes after the SDK's tabs (default). |
Returns
boolean: true when the panel was accepted; false when it was rejected. A rejected add logs addPanelToEvent rejected - <reason> and reports { message, panelType } on errorInformation. The reasons are listed in Custom panels.
Example
' Maestro.brs: call before or after config, both work
sub addMyStatsPanel()
panel = createObject("roSGNode", "MyStatsPanel") ' your component, extends MaestroCustomPanel
accepted = m.maestro.callFunc("addPanelToEvent", {
node: panel
panelType: panel.panelType
title: panel.title
iconUri: panel.callFunc("stagedIconUri")
order: panel.order
})
if not accepted then print "Custom panel rejected: "; m.maestro.errorInformation.message
end sub
Notes
- Call
addPanelToEventbefore or afterconfig: either order works. The panel is mounted on the next panel build when called before the config lands, or immediately when called after. - An add after the build rebuilds the tab strip and sends
rendered:channelsononSDKEventagain;panelsBuiltis not set again. - Calling with the same
panelTypeagain updates the tab if it is the same node, or replaces the panel with the new one (focus returns to the tab bar first). - Use
removePanelFromEventto take the panel out without destroying the SDK. - The
pkg:/icon path does not resolve inside the SDK's component library. CallstagedIconUri()on the node to copy it totmp:/and pass that path instead. - For the full contract, lifecycle and analytics of host-built panels, see Custom panels.