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

房东的猫 提交于 2021-01-28 12:13:06

问题


Why is the following script not disabling the push button, as it is supposed to do?

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

回答1:


The script action

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

will set the property value in the associated tagStructure (which describes the dialog), but it does not force an update of the dialog drawing. (Note that other UI commands like DLGTitle or DLGSetProgress do force an update.)

The command to disable/enable UI elements during display is SetElementIsEnabled. So use the following line instead of yours:

 self.SetElementIsEnabled("StopButton",0);

This will do what you want.


A second brute-force way would be to have the dialog window be closed and recreated, but I think you would generally want to avoid this.

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


来源:https://stackoverflow.com/questions/28160599/how-to-enable-disable-an-element-in-dialog-object-dlgenabled

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!