Table of Contents
Description
The <component> element defines all aspects of the component defined in a SceneGraph XML component file. Every SceneGraph XML component file must have exactly one <component> element that contains all other XML elements in the file, which may include:
- an <interface> element that defines the interface fields of the component
- zero or more <script> elements that define the BrightScript code used by the component
- a <children> element that contains the child <node> elements (either the built-in node classes or node classes extended from them) for the component, declared in XML markup
Attributes
The following attributes define a <component> XML element:
| Attribute | Required | Description |
|---|---|---|
| name | required | Specifies the name of the component, that allows you to create the component in your application. For example, if the name of the component is Important The |
| extends | required | Specifies the name of the built-in or extended SceneGraph scene or node class whose functionality is extended by this component. For example, |
| initialFocus | optional | Specifies the ID of a node declared in the XML file to have the initial remote control focus when the component is instantiated. |
| version | optional | Specifies the version of the SceneGraph API. The default is 1.0 if not specified. |
Example
The following <component> element defines a component named GridPanelExample, that contains <interface>, <script>, and <children> elements.
<component name = "GridPanelExample" extends = "GridPanel" initialFocus = "examplePosterGrid" >
<interface >
<field id = "gridcontenturi" type = "uri" onChange = "readpostergrid" />
</interface>
<script type = "text/brightscript" >
<![CDATA[
sub init()
m.top.panelSize = "full"
m.top.isFullScreen = true
m.top.leftPosition = 130
m.top.focusable = true
m.top.hasNextPanel = false
m.top.createNextPanelOnItemFocus = false
m.top.grid = m.top.findNode("examplePosterGrid")
end sub
sub readpostergrid()
m.readPosterGridTask = createObject("roSGNode", "ContentReader")
m.readPosterGridTask.contenturi = m.top.gridcontenturi
m.readPosterGridTask.observeField("content", "showpostergrid")
m.readPosterGridTask.control = "RUN"
end sub
sub showpostergrid()
m.top.grid.content = m.readPosterGridTask.content
end sub
]]>
</script>
<children >
<PosterGrid
id = "examplePosterGrid"
basePosterSize = "[ 512, 288 ]"
caption1NumLines = "1"
numColumns = "2"
numRows = "2"
itemSpacing = "[ 20, 20 ]" />
</children>
</component>