繁体   English   中英

Roku 中的对话框使用

[英]Dialog Box use in Roku

我试图显示一个对话框。 我在 Roku 中创建了一个普通应用程序。 在主场景中,Extends with the scene 我在主场景中创建了一个 one-child 并尝试显示对话框,还尝试在一个子场景中进行场景扩展并使用组件名称进行扩展。 在这里,我尝试了三种场景。 第一个Scenario Working But Two Scenario Generates Interface,不是成员。 我需要在子项或组件中使用对话框。 有什么解决方案吗?

第一种情况:

主要.xml

<component name="RokuApp" extends="Scene">
</component>

在我的对话框逻辑下方

主.brs

sub init()
  dialog = createObject("roSGNode", "Dialog")
  dialog.backgroundUri = "pkg:/images/rsgde_dlg_bg_hd.9.png"
  dialog.title = "Example Dialog"
  dialog.optionsDialog = true
  dialog.message = "Press * To Dismiss"
  m.top.dialog = dialog
end init()

第二种情况:

main.xml 在里面创建一个 ChildNode/另一个 XML 并与 Roku App 结合。

孩子.xml

<component name="Child" extends="Group">
</component>

孩子.brs

sub init()
  dialog = createObject("roSGNode", "Dialog")
  dialog.backgroundUri = "pkg:/images/rsgde_dlg_bg_hd.9.png"
  dialog.title = "Example Dialog"
  dialog.optionsDialog = true
  dialog.message = "Press * To Dismiss"
  m.top.dialog = dialog ' ' Interface not a member of BrightScript Component (runtime error &hf3)
end init()

第三种情况:

main.xml 在内部创建一个组件/另一个 XML 并与 Roku 应用程序结合。

组件.xml

<component name="Component" extends="RowList">
</component>

组件.brs

sub init()
  dialog = createObject("roSGNode", "Dialog")
  dialog.backgroundUri = "pkg:/images/rsgde_dlg_bg_hd.9.png"
  dialog.title = "Example Dialog"
  dialog.optionsDialog = true
  dialog.message = "Press * To Dismiss"
  m.top.dialog = dialog ' Interface not a member of BrightScript Component (runtime error &hf3)
end init()

但是,以上所有三个场景仅在场景正常工作的情况下进行扩展。 在另一种情况下,这两种情况都会生成错误接口,而不是 BrightScript 组件的成员(运行时错误 &hf3)任何人都知道该解决方案。

只有场景节点有一个名为“对话框”的字段。 Group 和 RowList 没有名为“dialog”的字段。

您可以使用下面的代码显示对话框

 m.resetDialog = createObject("roSGNode", "StandardMessageDialog") m.resetDialog.title = "Reset All Levels." m.resetDialog.message = ["You are about to reset all progress that you have made in the Game? Do you wish to proceed."] m.resetDialog,buttons = ["Continue". "Cancel"] ' observe the dialog's buttonSelected field to handle button selections m.resetDialog,observeFieldScoped("buttonSelected". "onResetButtonSelected") ' display the dialog scene = m.top.getScene() scene.dialog = m.resetDialog

并为按钮按下控件编写此代码

 if m.resetDialog.buttonSelected = 0 ' handle ok button here m.resetDialog.close = true else if m.resetDialog.buttonSelected = 1 ' handle cancel button here m.resetDialog.close = true end if

您也可以在组中使用此代码。 希望这会帮助你。 干杯

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM