KEVIVI
KEVIVI

Reputation: 67

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

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

Upvotes: 0

Views: 131

Answers (1)

BmyGuest
BmyGuest

Reputation: 3184

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

Upvotes: 0

Related Questions