| **Navigation:**  [[introduction.htm|Language Reference]] > App B - Events >====== Modal Events ====== | [[filesearch.htm#events|{{btn_prev_n.gif|Previous page}}]][[introduction.htm|{{btn_home_n.gif|Return to chapter overview}}]][[field independent events.htm|{{btn_next_n.gif|Next page}}]] | | || {{newc7.jpg|NewC7.jpg}} The following Events must always be treated as "modal": EVENT:LoseFocus EVENT:GainFocus EVENT:Dragging EVENT:Contracting EVENT:Expanding EVENT:PreAlertKey EVENT:TabChanging EVENT:Move EVENT:Size EVENT:Restore EVENT:Maximize EVENT:Iconize EVENT:Sized EVENT:Selected EVENT:Selecting Also, if a list box has the IMM attribute EVENT:ScrollUp EVENT:ScrollDown EVENT:PageUp EVENT:PageDown EVENT:ScrollTop EVENT:ScrollBottom EVENT:ScrollTrack EVENT:ScrollDrag When we refer to an event as "modal", it means that until the event is completed the runtime library can't continue its normal work. The main rule for writing code that responds to these events is that the event must be completed within a "finite" period of time. This means that the code you write for handling "modal" events should not invoke dialogs, include inner ACCEPT loops, call Message Boxes, or anything similar that would prevent the ACCEPT loop from completing the processing of the event. When your program needs to do something like this upon processing one of these events, a custom event should be posted to the front of the event queue. For example: **CASE EVENT()** **...** **OF EVENT:GainFocus** **POST(MyGainFocus,,, TRUE) !Post a user defined event to handle GainFocus action** **...** **OF MyGainFocus** **<;perform actions for gaining focus>** **...** **END**