我有一个需要 3 个选项的对话框,我已将其实现为按钮。最好使用模态对话框。我有这样的代码:
class testDialog : uiframe
{
void OnOne( object self )
{
Result( "Doing one\n" )
self.close()
}
void OnTwo( object self )
{
Result( "Two.\n" )
self.close()
}
void OnThree( object self )
{
Result( "Three.\n" )
self.close()
}
}
void ThreeButtonDialog(String description)
{
TagGroup dialog_items
TagGroup dialog_tags = DLGCreateDialog( "Test Dialog", dialog_items )
dialog_items.DLGAddElement( DLGCreateLabel( description ).DLGAnchor( "North" ) ).dlgexternalpadding(5,5)
TagGroup button_items
TagGroup button_fields = DLGCreateGroup( button_items )
DLGLayout( button_fields, DLGCreateTableLayout( 3, 1, 0 ) )
TagGroup one_button = DLGCreatePushButton("Option1", "OnOne")
TagGroup two_button = DLGCreatePushButton("Option2", "OnTwo")
TagGroup three_button = DLGCreatePushButton("Option3", "OnThree")
button_items.DLGAddElement(one_button)
button_items.DLGAddElement(two_button)
button_items.DLGAddElement(three_button)
dialog_items.DLGAddElement( button_fields )
Object dialog = alloc( testDialog ).init(dialog_tags)
dialog.Display("Test...")
DocumentWindow dialogwin=getdocumentwindow(0)
WindowSetFrameposition(dialogwin, 300, 200)
}
ThreeButtonDialog("test")
这在 DM2 中运行良好。然而,在 DM1 中,我得到一个错误:脚本对象没有关闭方法。
相反,我想我会尝试关闭窗口。将上面的 self.close 替换为:
DocumentWindow dialogwin=getdocumentwindow(0)
dialogwin.WindowClose(0)
这会导致 DM1 和 DM2 崩溃。有没有更好的办法?用单选按钮做一个模态对话框吗?