1

为什么下面的脚本没有像它应该做的那样禁用按钮?

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);
4

1 回答 1

1

脚本动作

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

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

在显示期间禁用/启用 UI 元素的命令是SetElementIsEnabled. 因此,请使用以下行而不是您的行:

 self.SetElementIsEnabled("StopButton",0);

这将做你想要的。


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

void Action( object self ) {
    self.LookUpElement("StopButton").DLGEnabled(0);
    self.close()
    self.display("")
    result( "button clicked\n" );
};
于 2015-01-27T22:49:29.350 回答