Pages: 1
Print
Author Topic: doModal in xft forms  (Read 3711 times)
dcramer
Member

Posts: 120


« on: March 17, 2010, 10:13:09 AM »

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
}

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
Logged

David Cramer
Technical Writer
Motive, an Alcatel-Lucent Company
Derek Read
Program Manager (XMetaL)
Administrator
Member

Posts: 2621



WWW
« Reply #1 on: March 18, 2010, 05:06:32 PM »

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

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.
« Last Edit: March 18, 2010, 05:16:26 PM by Derek Read » Logged
dcramer
Member

Posts: 120


« Reply #2 on: March 19, 2010, 07:38:28 AM »

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

Thanks,
David
Logged

David Cramer
Technical Writer
Motive, an Alcatel-Lucent Company
Pages: 1
Print
Jump to: