[GUI] The register/unregister callbacks issue

Peter Achten peter88@cs.kun.nl
Wed, 19 Mar 2003 12:31:41 +0100


Dear all,

A lot has been said about the register/unregister of callbacks. In my 
opinion a programmer should not have to register/unregister callbacks 
explicitly. The reason for this is that a decent GUI program already is 
supposed to do proper subsetting of the available callbacks by a number of 
means. For instance by opening/closing menu (elements), or 
enabling/disabling mouse, keyboard, window (element)s, menu(elements)... . 
It is up to the implementation of the platform what the appropriate action 
is in order to achieve an efficient implementation. On the X Windows 
platform this seems to be registering/unregistering of callbacks.

The MS Windows platform also does not like to keep track of unnecessary 
mouse movements. A program must explicitly set a flag in order to receive 
these events. For Object I/O this flag is always set. In addition, a 
'filter' function is associated with the keyboard and mouse callback. 
Suppose mouse events have type MouseState, then the corresponding filter 
function is of type (MouseState -> Bool). Before the OS sends a mouse event 
to the callback, it first checks if it passes the filter, and only if so, 
sends the event. This call is cheap and does not invoke IO actions (unless 
you use unsafePerformIO).

Regards,
Peter