If you are using FileMaker Pro 10 you could use an OnLayoutKeystroke script trigger to test if the user is in a field when they hit a key on the keyboard, and if not display your own custom message, and take them to a field.
I have just written this script and it seems to do the trick:
If [ IsEmpty ( Get ( ActiveFieldName ) ) ]
Show Custom Dialog [ Title: "Message"; Message: "Your message here."; Buttons: “OK” ]
Go to Field [ TABLE::FirstField ]
In testing this I notice to suppress the default message you need to have the Go to Field step in there before the end, and to stop the field being updated with the users keystroke you need to halt the script.
So then all you need to do after writing this script is to assign it to the layout by going into layout mode and selecting 'Layouts > Layout Setup...' and then under the 'Script Triggers' selecting OnLayoutKeystroke and choosing your new script when the dialog pops up.
Also if you want it to ignore keystrokes like arrow keys, escape and delete etc, change the If calculation to the following and they will be ignored
IsEmpty ( Get ( ActiveFieldName ) ) and not Length ( FilterValues ( "8¶9¶10¶13¶27¶28¶29¶30¶31¶32¶127" ; Code ( Get ( TriggerKeystroke ) ) ) )
And job done.
I hope this helps
You don't actually need your Go to Field and Halt Script steps - all you need is Exit Script [Result: 0].
That will 'eat' the keystroke for you since the trigger is pre-event.
Also I don't think you need the Length function in your second If calculation. This will do the job:
IsEmpty ( Get ( ActiveFieldName ) )
not FilterValues ( "8¶9¶10¶13¶27¶28¶29¶30¶31¶32¶127" ; Code ( Get ( TriggerKeystroke ) ) )
Thanks David, I did not know that about the Exit [Result ; 0], works much nicer now.
Thanks, Orlando and David. This is exactly what I was looking for.
In our new FileMaker Training Series courses, I spend some time looking at the implications of pre- and post-trigger events and how you can control them. Exiting the script with a false result is a big part of that. So getting to know which triggers are pre-event is helpful. Also useful for the Developer Certification exam. ;)