E Voelkl
E Voelkl

Reputation: 65

How to disable/enable dialog elements

In this short dialog, I am trying to enable/disable the integer field. The DLGEnabled() command does not seem to do anything here:

class BTW_Dialog : UIFrame
{   
     BTW_Dialog(object self) { Result( "\n Object `" + self.ScriptObjectGetClassName() + "` ID:" + self.ScriptObjectGetID() + " created."   ); }
    ~BTW_Dialog(object self) { Result( "\n Object `" + self.ScriptObjectGetClassName() + "` ID:" + self.ScriptObjectGetID() + " destroyed." ); }

    TagGroup CreateDLGTagGroup( object self )
    { 
        //  Dialog building method
        TagGroup DLGtgs, DLGItems
        DLGtgs = DLGCreateDialog( "Analyze", DLGItems );

        TagGroup RadioList = DLGCreateRadioList( 0, "AActOnRadio" )
            RadioList.DLGAddRadioItem( "LP", 0 ).DLGIdentifier("0").DLGSide( "Left" );
            RadioList.DLGAddRadioItem( "LF", 1 ).DLGIdentifier("1").DLGSide( "Left" );
        DLGitems.DLGAddElement(RadioList).DLGAnchor("West");

        TagGroup field = DLGCreateIntegerField( 55, 4 ).DLGSide( "Left" ).DLGIdentifier("xyz");
        DLGitems.DLGAddElement(field).DLGAnchor("West");

        return DLGtgs
    } 

    object LaunchAsModelessDialog( object self )
    { 
        self.init( self.CreateDLGTagGroup() );
        self.Display( "Analyze" );
        return self
    } 

    void AActOnRadio( object self, tagGroup itemTG )
    { 
        number radioButtonState = itemTG.DLGGetValue();
        vtagGroup xyz_tag = self.LookupElement("xyz")
        if(radioButtonState)
        {   //  trying to disable integer field:  <<<-------||
            DLGEnabled( xyz_tag, 0)
        } 
    }
}   

Alloc(BTW_Dialog).LaunchAsModeLessDialog();

Is there any other command to disable and/or hide the integer field when the radio button is pressed? Thanks.

Upvotes: 0

Views: 72

Answers (1)

BmyGuest
BmyGuest

Reputation: 3184

The command you're looking for is

void SetElementIsEnabled( ScriptObject, String identifier, Boolean is_enabled )

i.e. in your example replace

DLGEnabled( xyz_tag, 0)

by

self.SetElementIsEnabled(  "xyz", 0 )

Note, there is a similar command to make a dialog element "hidden", which is

void SetElementIsShown( ScriptObject, String identifier, Boolean is_shown )

Upvotes: 0

Related Questions