Copy link to clipboard
Copied
Why, if the input field is empty and the user pressed the OK button, the function is not interrupted and the Else block is processed?
app.addSubMenu({ cName: "Test", cParent: "Help", nPos: 0})
app.addMenuItem({ cParent: "Test", cName: "My_button", nPos: 2, cExec: "NumberX()", cEnable: "event.rc = (event.target != null);"});
function NumberX()
{
Msg = app.response(" ", " ");
if (Msg == null) {
app.alert("The user did not enter anything and clicked Ok");
return;}
else
{
app.alert("The user entered some number: " + Msg);
}
};
app.trustedFunction(NumberX);
The documentation says app.response returns null if the user clicks Cancel. Your user is not doing this!
Copy link to clipboard
Copied
The documentation says app.response returns null if the user clicks Cancel. Your user is not doing this!
Copy link to clipboard
Copied
Thank you, now I found it in API
Tell me how you can handle the OK button? or for this you need to use app.execDialog ();
Copy link to clipboard
Copied
Just replace null in your code with ""...
Copy link to clipboard
Copied
I have already tried this option, but then the Cancel button and closing the window with a cross do not work correctly
Copy link to clipboard
Copied
If they click OK and don't enter anything the returned value is an empty string, which is not the same as null.
Copy link to clipboard
Copied
You can handle both scenarios at the same time, like this:
if (Msg == null || Msg=="")
Copy link to clipboard
Copied
Once again, many thanks!