5.1 Event Handling in Windows

All user activities with the mouse, keyboard, etc. are turned into events by the underlying window system. Lidskjalv turns the window relevant events into invocations of virtual procedure patterns, defined in the eventhandler of the window. Eventhandler defines the following virtual patterns: onActivate, onDeactivate, onRefresh, onKeyDown, onMouseDown, onMouseUp, and onAboutToClose.

These patterns are invoked when the corresponding event occurs and further bindings of these patterns may specify actions to be executed then. OnActivate is invoked when this window is becoming the active window and onDeactivate is invoked when another window becomes the active window. OnRefresh is invoked when the window has been corrupted (e.g. when the window is opened or when another window, which is obscuring parts of this window, is moved). OnKeyDown is invoked when the user presses a key on the keyboard. OnKeyDown takes one parameter which is the character associated with that key. OnMouseDown is invoked when the user presses the mouse button and onMouseUp is invoked, when the user releases the mouse button. OnAboutToClose is invoked when the mouse button is pressed when the cursor is located in the Close box. E.g.:

Program 2: windowWithEvents.bet

ORIGIN '~beta/guienv/guienv'
--- program: descriptor ---
guienv
(# eventWindow: @window
     (# open:: 
          (# 
          do (100,100)->position;
             (300,300)->size;
             'windowWithEvents'->title
          #);
        eventhandler::
          (# onAboutToClose:: (# do terminate #);
             onRefresh:: (# do 'refresh'->putline #);
             onMouseDown:: (# do 'mouseDown'->putline #)
          #)
     #)
do eventWindow.open;
#)

Program 3: screendumps (Windows 95)

[3kb 144x154 GIF]   [9kb 144x154 GIF]

The refresh and mouseDown printouts originates from user interaction with the window.


Lidskjalv: User Interface Framework - Tutorial
© 1995-2004 Mjølner Informatics
[Modified: Friday October 27th 2000 at 14:56]