« [Challenge] Spotlight on Tabs | Main | [Movie] Introduction to Tool Tips »

October 25, 2004

[Tip] Triggering an Immediate Dialog on Entering and Exiting a Field

by Jan Aleman

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:

    globals.busy = 1
    plugins.dialogs.showDialog( "a","enterdialog")
    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.

Posted by David Workman on October 25, 2004 at 07:56 AM in Tips | Permalink


TrackBack URL for this entry:

Listed below are links to weblogs that reference [Tip] Triggering an Immediate Dialog on Entering and Exiting a Field:


The comments to this entry are closed.