[Tip] Triggering an Immediate Dialog on Entering and Exiting a Field
by Jan Aleman
Servoy
Let's say you want to show a dialog the moment somebody enters a field and one the moment somebody leaves it. If you create a dialog popup for both these events guess what will happen? You'll get stuck in a indefinite loop. When you enter the field the popup will be triggered which on its turn triggers the onLeave event. The dialog is still showing though so the second dialog is waiting for the first to complete, and so on.
You'll need to trick the event driven system to make it work. It's easy, all you need is one global variable.
1. Create a global, call it "busy".
2. Use this method for onFocusGained property of the field:
if(!globals.busy)
{
globals.busy = 1
plugins.dialogs.showDialog( "a","enterdialog")
}
else
{
globals.busy = 2
}
3. Use this method for onFocusLost property of the field:
if(globals.busy == 2)
{
globals.busy = 0;
plugins.dialogs.showDialog("b","this is the leave dialog")
}
The global is used to determine which state you are in so that the proper dialog is displayed.