如何在BrightScript中使用replaceChild替换PanelSet

时间:2017-02-20 20:40:27

标签: roku brightscript scenegraph

我使用PanelSet类创建一个由两个面板组成的设置屏幕:

    左侧的
  • panelA显示整体设置选项列表
  • panelB显示在右侧,包含panelA上每个项目的不同选项列表

当用户更改Panel上的焦点项目时,如何替换右侧显示的panelA

Roku's documentation声明您必须使用方法replaceChild,但我无法弄清楚它应该如何工作,或者任何示例。这就是我的尝试,但它不起作用:

function showPanelInfo()
    if m.panelA.list.itemFocused = 0
        m.panelset.replaceChild(m.panelB, 3)
    else
        m.panelset.replaceChild(m.panelC, 3)
    end if
end function

Function init()
    m.panelset = createObject("roSGNode", "PanelSet")

    ' Left-hand side panel with two items list
    m.panelA = m.panelset.createChild("OptionsListPanel")

    ' Right-hand side panels with different lists for each item on left-hand side panel
    m.panelB = m.panelset.createChild("OptionsBPanel")
    m.panelC = createObject("roSGNode", "OptionsCPanel")

    m.panelA.list.observeField("itemFocused", "showPanelInfo")
...
end function

1 个答案:

答案 0 :(得分:0)

面板集没有nextPanel。仅列表面板和网格面板具有m.panelA.nextPanel = m.panelB 。因此,

Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button2.Click
   Dim My_Thread as Threading.Thread
   My_Thread = New Threading.Thread(AddressOf Module1.MyTest)
   My_Thread.Start()
End Sub