Catching mouse events

The program Mouse.m3 illustrates different kinds of mouse events. The application displays a blank area on the left where you can click with the mouse. The event is analyzed and displayed in the five fields on the right. They are:
what changed
which button was involved in the event (left, right or middle).
time
the Trestle time stamp at which the event was generated.
cp
the current cursor position in the VBT's coordinate system.
modifiers
which keys from among the option, shift, lock, and control keys that were pressed down when the event was generated.
click type
what kind of mouse click: FirstDown, OtherDown, FirstUp or LastUp.
click count
the number of times the mouse button was clicked rapidly in row just before this event was generated.

The blank area in the window that catches the mouse events is created by a subtype of LeafVBT. A LeafVBT is so primitive that it does not even redraw itself. So we override the repaint method with one that does the repainting. In this case there is nothing important to do, just fill in with the background color. The mouse events are caught by supplying our own mouse method which does much more than the default mouse method (which does nothing).

Our mouse method, called MouseEvent is in Event.m3. It receives a data structure called MouseRec. The method extracts the various pieces of the structure and displays them in the appropriate text fields of the main application.

Two views of the application while it is running are show in: