General XMetaL Discussion
XMetaL Community Forum › General XMetaL Discussion › doModal in xft forms
-
dcramer March 17, 2010 at 4:13 pm
doModal in xft forms
March 17, 2010 at 4:13 pmParticipants 1Replies 2Last Activity 12 years, 10 months agoFrom 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,
DavidDerek Read March 18, 2010 at 11:06 pm
Reply to: doModal in xft forms
March 18, 2010 at 11:06 pmActually, 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) = 2You 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.
dcramer March 19, 2010 at 1:38 pm
Reply to: doModal in xft forms
March 19, 2010 at 1:38 pmOk, 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 -
AuthorPosts
- You must be logged in to reply to this topic.