The LEAVE event

Rabbit

Member
Hi all,

I have a LEAVE event with some error checking coding but I don't want this event be fired when I close the window.

I can over come this problem by using the cancel button with AUTO-END-KEY option. But how about if user click on the close button of the window (i.e. the standard close button of each window). I have try to use the following statement :

APPLY "CHOOSE":U TO btn-close.

I use this statement in order to fire the cancel button, but it's does not work, please help!

Rabbit
 

flaticon

New Member
HI Rabbit,

you try this, on the trigger block code of your cancel button:

ON "CHOOSE" OF BTN-CLOSE OR WINDOW-CLOSED OF {&WINDOW-NAME} DO:
..
.
.
.
END.

or this:

APPLY "CHOOSE":U TO btn-close.
RETURN NO-APPLY.


flaticon
 
Some advice:

1) Using the LEAVE event for validation is asking for trouble
2) Triggers can't be called recursively
3) All methods of exiting a window should filter through a single procedure or event
4) In my experience, end-users HATE being told how, when and where to enter data onto the form, and in what sequence. Software is supposed to be user-friendly.

If you really do need to use the LEAVE event for validation, then make the trigger code subject to a logical variable. This is a very simple solution that's clear to other developers and is easy to maintain. For example:

ON LEAVE OF FILL-IN-1
DO:
IF NOT lv-closing THEN
DO:
/* perform validation */
END.
END.

As all methods of exiting should filter through a single procedure, you can set lv-cancel to TRUE within that procedure to disable the validation.

Using something like AUTO-END-KEY is okay, but its effect isn't always immediately obvious to developers.

HTH
 

NickA

Member
I agree with Mike Carroll that you shouldn't use the LEAVE event for any kind of STRICT validation. This kind of validation should only occur when you're trying to commit what you've done (EG Clicking on an OK button).

However, you might be able to use LAST-EVENT:WIDGET-ENTER to check which widget you are going to next after the LEAVE?

Just a thought.
 
Top