General XMetaL Discussion

  • dcramer

    doModal in xft forms

    Participants 1
    Replies 2
    Last Activity 12 years, 6 months ago

    From experimentation, I've deduced that the following does what I expect:

    [code]
    var xftPath = “path_to\SomeForm.xft”;                                                                 
    var dlg=Application.CreateFormDlg(xftPath);

    if(dlg.DoModal == 1){
    //an OK button pressed or OK method called
    }else if(dlg.DoModal == -1){
    //a Cancel button or Cancel method called
    }
    [/code]

    Could you confirm that this is the right way to do a dialog with an ok and cancel button and if so, add it to the documentation?

    Thanks,
    David

    Reply

    Derek Read

    Reply to: doModal in xft forms

    Actually, the return values are 1 and 2:
    OK button (or “OK” the form via some other means) = 1
    Cancel button (or dismiss the form via some other means) = 2

    You can confirm this by running the following code:

    [code]//XMetaL Script Language JScript:
    var xftPath = Application.Path + “\forms\ulink.xft”;
    var dlg=Application.CreateFormDlg(xftPath);
    var retval = dlg.DoModal();
    Application.Alert(retval);[/code]

    The sample form in this case is really meant to be used with the Journalist demo, but should launch with the code above regardless (just don't fill anything in before clicking OK / Cancel / Close button or ESC key). Or substitute your own form at line 2 for xftPath.

    I agree, this should be documented.

    Reply

    dcramer

    Reply to: doModal in xft forms

    Ok, that's working much better. I was fooled because I'd put one dlg.DoModal in an if and a second in an else if. The second one is always -1:

    [code]
    Application.Alert(dlg.DoModal);// This is 1 or 2 depending on whether you did OK or Cancel
    Application.Alert(dlg.DoModal);// This is always -1
    [/code]

    Thanks,
    David

    Reply

  • You must be logged in to reply to this topic.

Lost Your Password?

Products
Downloads
Support