Whenever the user moves the mouse, clicks or releases a mouse button, or presses a key on the keyboard, an event is generated for some window. The window that receives the event depends on the current state of the graphic display:
When the user clicks in a window, the window ``grabs'' the mouse, so that all mouse events go to that window until the mouse button is released (regardless of the location of the cursor). As a result, a user can click on a scrollbar thumb and drag it without keeping the cursor strictly inside the scrollbar control.
A canvas propagates mouse and keyboard events to its on-event and on-char methods. Controls, such as buttons and list boxes, handle keyboard and mouse events automatically, eventually invoking the callback procedure that was provided when the control was created.
Although most graphical events are delivered directly to the receiving window, mouse and keyboard events are delivered specially. Each ancestor of the receiving window gets a chance to intercept the event through the on-subwindow-event and on-subwindow-char methods. See the method descriptions for more information.
The default on-subwindow-char method for a
top-level window intercepts keyboard events to detect menu-shortcut
events and focus-navigation events. See
on-subwindow-char in frame% and
on-subwindow-char in dialog% for details. Certain
OS-specific key combinations are captured at a low level, and cannot
be overridden. For example, under Windows and X, pressing and
releasing Alt always moves the keyboard focus to the menu
bar. Similarly, Alt-Tab switches to a different application under
Windows.