当我创建容器(例如选项卡、框或组)时,参数之一是container_items。起初,我总是创建container_items。我想我必须使用container_items.DLGAddElement()来添加元素。但我发现使用container.DLGAddElement()可以达到相同的结果。
此外,对于某些小部件,例如单选按钮,它也有 container_items 参数。
谁能给我一些信息,我们什么时候会使用 contains_items?
DLGCreateTab( TagGroup &tab_items, string label )
DLGCreateBox( String title, TagGroup &items )
DLGCreateGroup( TagGroup &items )
DLGCreateRadioList( TagGroup &items )
(几乎)所有 DLG... 命令本质上都是构建 tagGroup 的实用方法,其中 tagGroup 描述了对话框的样子。为了调试或学习目的,显示此标签组通常很有帮助。如果不同的命令产生相同的 tagGroup,那么它们在功能上确实是相同的。
要显示标签组,您可以使用
TagGroupOpenBrowserWindow(tagGroup myTags, string Name, bool isFileBased)
其中
mytags
是要显示的标签组(您使用 DLGCreateDialog 创建的标签组)
和
其中
Name
只是所显示对话框的标题并且
与
isFileBased
指示对话框关闭后是否应保存标签(如果更改)。
number addToContainer = 1
string infoStr = "Items added to " + (addToContainer?"Container":"ContainerItems")
taggroup dlg, dlgItems
dlg = DLGCreateDialog("Test",dlgItems)
taggroup box, boxItems
box = DLGCreateBox("Box 1",boxItems)
if ( addToContainer )
{
box.DLGAddElement(DLGCreateLabel(infoStr))
dlg.DLGAddElement(box)
}
else
{
boxItems.DLGAddElement(DLGCreateLabel(infoStr))
dlgItems.DLGAddElement(box)
}
dlg.TagGroupOpenBrowserWindow(infoStr,0)
Alloc(UIFrame).Init(dlg).Display(infoStr)
如您所见,两种方法都为您提供相同的对话框和(几乎)相同的标签结构,但添加到容器而不是容器项目标签会添加“无效”标志。我猜想,添加到项目是“正确”的方式,但是当添加到容器本身时,底层代码会为您“修复”它。很可能在以后的状态中添加了一些便利行为。