Search code examples
event-handlingopenedgeprogress-4gl

How to avoid an event being overwritten by a general one?


I have a main application, with following event:

ON ESCAPE ANYWHERE

I've just created a frame within a window, where I'd like to add an event:

ON ESCAPE ...

This, however, seems not to work as the main application already has an ON ESCAPE ANYWHERE. Is there something like ON ESCAPE OVERWRITES DEFAULT to create an event for my subwindow?

Thanks in advance


Solution

  • From the documentation notes:

    A trigger defined with the ON statement remains in effect until one of the following occurs:

    • Another ON statement defines another trigger (or REVERT) for the same event and widget
    • For a non-persistent trigger, the procedure or trigger block in which the ON statement appears terminates

    So I think your main application trigger is defined after your own trigger, overwriting it. If you can be specific enough, you should be fine:

    on escape anywhere do:
       message 'escaping from anywhere' view-as alert-box.     
    end.
    
    define frame fr1
       cc1 as char 
       cc2 as char 
       with side-labels
       .   
    
    do with frame fr1:
    
       enable all.   
       
       on escape of cc1 do:
          message "escaping from cc1 in frame 1" view-as alert-box.
       end.
       
    end.
    
    view frame fr1.
    wait-for close of frame fr1.