Instead of show custom dialog use New window and select a layout designed for use as a global field, This can allow you better options for controlling input in that field--such as an OnObjectKeystroke trigger that disables certain keys such as the + and space keys from being able to input characters into the field. This can even be done to limit the - operator to only being accepted as the first character in the field so that negative values can be entered but not 5 - 5.
This layout could also use a portal to a related table for collecting data to make it easier for your users to enter multiple values while your dialog is open for accepting input.
Hi Phil, Thank you for your reply.
I forgot to mention that we are using FMP11 and the new window may get forgotten open and create confusion.
In fact I use already dialog windows in other solutions on FMP12.
I need the custom dialog because the user need to keep the primary window in background for quick check data while typing. But cannot access the primary window until submit the data in the dialog box.
It's important to tell people what version you are using when it's not the latest version. Otherwise, people can waste time posting a suggestion that you cannot use with your older version.
But I kept such windows open in FileMaker 11 in a modal state all the time. It was a bit of a kludge, but it worked. (Note: in FileMaker 13, you not only have modal windows, you can use a popover instead of the window and this is often a nicer option.)
Here's how to script the creation of a pseudoModal dialog in FileMaker 11 or older with the New Window script step:
Allow User Abort [off] --. only add this after thorough testing as this can trap you in a state where you have to force quit
Go to Layout
Show/Hide Tool Bars [Hide]
Adjust Window [resize to fit]
Pause/Resume Script [indefinitely]
You put buttons on the layout used with this window that perform a script to close the window. Specify either the "Halt script" option on the button or include a Halt Script step at the end of the script. This step will interrupt what is otherwise an endless and uninterruptible infinite loop that traps the window into a modal state. If you have FileMaker Advanced, you can install a custom menu that performs a script to close the window and halt the paused script in place of the standard Close Window menu option. This can enable the close window control in the corner of your pseudomodal dialog window.
Hi Phil, Thank you for your patience and explanations.
Creating a new dialog layout in a new window as you described would include a bit too much time and effort as the system and the scripts involved are already pretty complex. However I'll keep in mind how you created the pseudoModal dialog window, which I can use in future development.
After consulting with other developers I've managed to solve the problem by adding a simple script step to validate the data typed by the user before continue the script:
Filter ( GLOBALFIELD ; "1234567890-" ) = GLOBALFIELD and Patterncount ( GLOBALFIELD ; "-" ) ≤ 1 and Position ( GLOBALFIELD ; "-" ; 1 ; 1 ) ≤ 1
If validation fails, the script will return an error message and exit script.