Modal windows - the "OK" button<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />Hi - I want to create a modal window that requests a response from the user, something like this:
teb = text edit box("");
ok = button box("OK");
nw = new window("My Modal Window", << modal(1),
h list box(text box("Type here: "), teb),
ok
);
How can I prevent the window from closing if the user clicks on “OK” without supplying a response? I’ve tried adding assorted scripts to the “OK” button to see if teb contains a string of greater than zero length, and then only closing the window if it has, but I can’t seem to find the right syntax: the window always closes regardless.
I note that the window supplies an "OK" button even if I don't include it (presumably because it has to have one), so I'm wondering whether it is replacing my "OK" button with one of its own. Is it possible that that's the problem?
Many thanks
Re: Modal windows - the "OK" button<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />Hello,
You can try the following--
Change from modal to nonmodal and and add a "Cancel" button box.
I would suggest moving your text edit box and "OK" button box as well.
The messages will be printed to the log with each button that is selected.
Best,
Stan
!-
nw = new window("My Modal Window", << nonmodal,
h list box(text box("Type here: "),teb = text edit box("") ),
Button Box("OK", usertext = teb <<Get Text;
If(usertext == "", throw("!Error 001: (No Value)--Enter a value before proceeding"),
nw<<Close Window; Clear log(); Write("You entered the text = " || char(usertext))
)),
Button Box( "Cancel", nw<<Close Window; Clear Log(); Write("User Cancelled.") )
);
-!
Re: Modal windows - the "OK" buttonDodo,
The OK button or its "equivalent" is required in a modal window. The point is to construct your modal window so that the user makes choices and then clicks "OK" or "Cancel" to those choices. The equivalent is "Yes" and "No".
Try the following:
New Window("Modal Demo", <
Textbox("Do you really want to do that?"),
ButtonBox("Yes"),
ButtonBox("No")
);
So, you must always construct your modal dialog to end in "Yes" or "No" or "OK" and "Cancel".
If you think about this, it makes sense. You have two choices: accept or do not accept.
To be more specific to your question, you can disable the "OK" or "Yes" button until something is done. Try the following:
Stuff Selected = "";
Entry Window = List(Button(-1));
Ask the User Expr = Expr (
Entry Window = New Window("Modal Demo", < TextBox("Please enter some stuff?"),
Stuff = TextEditBox("", <&amp;amp;amp;amp;amp;amp;nbsp; Yes Button = ButtonBox("Yes", &amp;amp;amp;amp;amp;amp;lt;&amp;amp;amp;amp;amp;amp;lt;Enable(0)),&amp;amp;amp;amp;amp;amp;lt;BR /&amp;amp;amp;amp;amp;amp;gt; );&amp;amp;amp;amp;amp;amp;lt;/P&amp;amp;amp;amp;amp;amp;gt;&amp;amp;amp;amp;amp;amp;lt;P&amp;amp;amp;amp;amp;amp;gt;);&amp;amp;amp;amp;amp;amp;lt;/P&amp;amp;amp;amp;amp;amp;gt;&amp;amp;amp;amp;amp;amp;lt;P&amp;amp;amp;amp;amp;amp;gt;While(Stuff Selected == "" | Entry Window["Button"] == -1,&amp;amp;amp;amp;amp;amp;lt;/P&amp;amp;amp;amp;amp;amp;gt;&amp;amp;amp;amp;amp;amp;lt;P&amp;amp;amp;amp;amp;amp;gt;Ask the User Expr;&amp;amp;amp;amp;amp;amp;lt;/P&amp;amp;amp;amp;amp;amp;gt;&amp;amp;amp;amp;amp;amp;lt;P&amp;amp;amp;amp;amp;amp;gt;);&amp;amp;amp;amp;amp;amp;lt;/P&amp;amp;amp;amp;amp;amp;gt;&amp;amp;amp;amp;amp;amp;lt;P&amp;amp;amp;amp;amp;amp;gt;&amp;amp;amp;amp;amp;amp;lt;/P&amp;amp;amp;amp;amp;amp;gt;&amp;amp;amp;amp;amp;amp;lt;P&amp;amp;amp;amp;amp;amp;gt;Michael&amp;amp;amp;amp;amp;amp;lt;/P&amp;amp;amp;amp;amp;amp;gt;&amp;amp;amp;amp;amp;amp;lt;/BODY&amp;amp;amp;amp;amp;amp;gt;&amp;amp;amp;amp;amp;amp;lt;/HTML&amp;amp;amp;amp;amp;amp;gt;&amp;amp;amp;amp;amp;amp;lt;/lingo-body&amp;amp;amp;amp;amp;amp;gt;
Re: Modal windows - the "OK" buttonThank you very much. That seems to work!