Roku 有内置的焦点管理系统吗?

问题描述 投票:0回答:1

我对此进行了很多研究,对于 Roku 管理焦点的方式得到了一些不同的答案。我知道 Apple TV 有一个复杂的管理器,可以确定下一个重点元素应该是什么,但在 Roku 中,我在实现简单行为时遇到了一些困难。

例如,以这个基本的场景图形组件为例:

<component name="HelloWorld" extends="Scene" initialFocus="exampleButton">
      <script type="text/brightscript" uri="helloworld.brs" />
      <children>
            <Group>
                  <ButtonGroup>
                        <Button
                              id="exampleButton"
                              text="Example Button"
                              showFocusFootprint="true"
                              minWidth="240" />
                        <Button
                              id="exampleButton2"
                              text="Example Button"
                              showFocusFootprint="true"
                              minWidth="240" />
                  </ButtonGroup>

                  <ButtonGroup focusable="true"
                        translation="[0,200]">
                        <Button
                              id="exampleButton3"
                              text="Example Button"
                              showFocusFootprint="true"
                              minWidth="240" />
                        <Button
                              id="exampleButton4"
                              text="Example Button"
                              showFocusFootprint="true"
                              minWidth="240" />
                  </ButtonGroup>
            </Group>
      </children>
</component>

它包含两个按钮组,彼此垂直显示。由于某种原因,我无法从第一个按钮组导航到第二个按钮组,反之亦然。这对我来说似乎是错误的,并且是一个巨大的危险信号。我们是否期望为屏幕上的每个视图实现焦点模式?我是不是错过了什么?

如果我不设置

initialFocus
属性,则不会获得任何焦点,我也无法执行任何操作。我在后面的代码中唯一调用的是
m.top.setFocus(true)
,因为如果没有它,即使
initialFocus
属性也无法工作。

只要对对焦系统有一些清晰的了解,我们将不胜感激!谢谢!

对于一个更简单的例子,这也不起作用:

<component name="HelloWorld" extends="Scene" initialFocus="exampleButton">
      <script type="text/brightscript" uri="helloworld.brs" />
      <children>
            <Button
                  id="exampleButton"
                  text="Example Button"
                  showFocusFootprint="true"
                  minWidth="240" />
            <Button
                  id="exampleButton2"
                  text="Example Button 2"
                  showFocusFootprint="true" 
                  minWidth="240"
                  translation="[0,240]" />
      </children>
</component>
    

这是设计使然吗?为什么?

我尝试了很多东西,比如使用

LayoutGroup
或其他容器。我真的不想为每个自定义组件发明一个焦点管理系统。

navigation roku brightscript scenegraph
1个回答
0
投票

答案是“是的,但不是真的”。

就像如果你在同一个容器中有元素一样,brightscript 会尝试处理它。但如果您要从一个组件转移到另一个组件,您最好自己制作。

hasFocus() 将成为你最好的朋友。

© www.soinside.com 2019 - 2024. All rights reserved.