Exit [Result: 0] not trapping button press
I just noticed the following problem. I have a series of script triggers that monitor data entry and, when they see an inappropriate value in a given field, they issue an informative Custom Dialog message and then do an Exit [Result: 0]. They are called on Object Exit. This generally works fine, not letting the user leave the field with inappropriate data. However, I just noticed that if the user leaves the field by clicking on a button somewhere else in the layout, the button script isn't always stopped out. It seems to depend on what's in the button script. For instance, a button script that simply changes the layout, not calliing other scripts, seems to have no problem.
I have resorted to having such a script trigger script set a $$StopButtons variable to 0 when it starts, and reset it to 1 if it sees inappropriate data entry, then do an Exit [Result: 0].
I then placed the following at the beginning of each button script on such a layout:
Commit Records (not validation an no pause)
If [ $$StopButtons = 1 ]
This works, but seems rather inelegant. Am I missing something more straightforward that can be done here?