如何启用/禁用对话框对象中的元素 - DLGEnabled

How to enable-disable an element in dialog object - DLGEnabled

为什么下面的脚本没有像预期的那样禁用按钮?

class ElementEnableTest : UIFrame {

    void Action( object self ) {
        self.LookUpElement("StopButton").DLGEnabled(0);
        result( "button clicked\n" );
    };

    ElementEnableTest( object self ) {
        TagGroup tgDialog = DLGCreateDialog( "" );
        TagGroup tgButton = DLGCreatePushButton("stop","Action");
        tgButton.DLGIdentifier("StopButton");
        tgDialog.DLGAddElement( tgButton);
        self.init( tgDialog );
        self.Display( "test" );
    };
};

alloc(ElementEnableTest);

脚本动作

 self.LookUpElement("StopButton").DLGEnabled(0);

将在关联的 tagStructure(描述对话框)中设置 属性 值,但它不会强制更新对话框绘图。 (请注意,其他 UI 命令,如 DLGTitleDLGSetProgress 会强制更新。)

在显示期间对disable/enable UI 个元素的命令是SetElementIsEnabled。因此,请使用以下行代替您的行:

 self.SetElementIsEnabled("StopButton",0);

这会做你想做的事。


第二种蛮力方法是关闭并重新创建对话框 window,但我认为您通常希望避免这种情况。

void Action( object self ) {
    self.LookUpElement("StopButton").DLGEnabled(0);
    self.close()
    self.display("")
    result( "button clicked\n" );
};