如何禁用/启用对话框元素

时间:2018-04-09 12:17:04

标签: dm-script

在这个简短的对话框中,我试图启用/禁用整数字段。 DLGEnabled()命令似乎在这里没有做任何事情:

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

按下单选按钮时是否还有其他命令禁用和/或隐藏整数字段?感谢。

1 个答案:

答案 0 :(得分:1)

您正在寻找的命令是

void SetElementIsEnabled( ScriptObject, String identifier, Boolean is_enabled )

即。在您的示例中替换

DLGEnabled( xyz_tag, 0)

通过

self.SetElementIsEnabled(  "xyz", 0 )

注意,有一个类似的命令可以使对话框元素“隐藏”,即

void SetElementIsShown( ScriptObject, String identifier, Boolean is_shown )