User Tools

Site Tools


accept_the_event_processor_.htm
Navigation:  Language Reference > 12 - Execution Control > Control Structures >====== ACCEPT (the event processor) ====== Previous pageReturn to chapter overviewNext page

NewC7.jpg

ACCEPT

statements

END

blk2blue.jpg

ACCEPT The event handler.
statements Executable code statements.

The ACCEPT loop is the event handler that processes events generated by Windows for the APPLICATION or WINDOW structures. An ACCEPT loop and a window are bound together, in that, when the window is opened, the next ACCEPT loop encountered will process all events for that window.

ACCEPT operates in the same manner as a LOOP–the BREAK and CYCLE statements can be used within it. The ACCEPT loop cycles for every event that requires program action. ACCEPT waits until the Clarion runtime library sends it an event that the program should process, then cycles through to execute its statements. During the time ACCEPT is waiting, the Clarion runtime library has control, automatically handling common events from Windows that do not need specific program action (such as screen re-draws).

The current contents of all STRING control USE variables (in the top window of each thread) automatically display on screen each time the ACCEPT loop cycles to the top. This eliminates the need to explicitly issue a DISPLAY statement to update the video display for display-only data. USE variable contents for any other control automatically display on screen for any event generated for that control, unless PROP:Auto is turned on to automatically display all USE variables each time through the ACCEPT loop.

Within the ACCEPT loop, the program determines what happened by using the following procedures:

EVENT() Returns a value indicating what happened. Symbolic constants for events are in the EQUATES.CLW file.
FIELD() Returns the field number for the control to which the event refers, if the event is a field-specific event.
ACCEPTED() Returns the field number for the control to which the event refers for the EVENT:Accepted event.
SELECTED() Returns the field number for the control to which the event refers for the EVENT:Selected event.
FOCUS() Returns the field number of the control that has input focus, no matter what event occurred.
MOUSEX() Returns the x-coordinate of the mouse cursor.
MOUSEY() Returns the y-coordinate of the mouse cursor.

Two events cause an implicit BREAK from the ACCEPT loop. These are the events that signal the close of a window (EVENT:CloseWindow) or close of a program (EVENT:CloseDown). The program's code need not check for these events as they are handled automatically. However, the code may check for them and execute some specific action, such as displaying a “You sure?” window or handling some housekeeping details. A CYCLE statement at that point returns to the top of the ACCEPT loop without exiting the window or program.

Similarly, there are several other events whose action can also be terminated by a CYCLE statement: EVENT:Move, EVENT:Size, EVENT:Restore, EVENT:Maximize, and EVENT:Iconize. A CYCLE statement in response to any of these events stops the normal action and prohibits generation of the related EVENT:Moved, EVENT:Sized, EVENT:Restored, EVENT:Maximized, or EVENT:Iconized.

Example:

CODE

OPEN(Window)

ACCEPT                !Event handler

 CASE FIELD()  

 OF 0                 !Handle Field-independent events

  CASE EVENT()

  OF EVENT:Move

    CYCLE             !Do not allow user to move the window

 OF ?Field1            !Handle events for Field1

  CASE EVENT()

  OF EVENT:Selected

    ! pre-edit code for field1

  OF EVENT:Accepted

    ! completion code for field1

  END

 END !CASE FIELD

END !ACCEPT LOOP

See Also:

EVENT

Modal Events

APPLICATION

WINDOW

FIELD

FOCUS

ACCEPTED

SELECTED

CYCLE

BREAK

POST

accept_the_event_processor_.htm.txt · Last modified: 2021/04/15 15:56 by 127.0.0.1