Dragging the mouse

A drag switch generates events while a mouse button is down and has moved since the last time an event was generated. Events are reported to the switch even when the mouse is outside the switch's domain. A draw switch has two methods called during and callback. and callback that can be overridden by clients to do some actions. The during method is called each time the mouse moves from its current cursor position after a mouse button has been pressed on the drag switch. The callback method is called when the mouse is released.

The program Drag.m3 uses a drag switch. The text field is used to display the current position of the cursor while a button is held down and the cursor is being dragged. When the mouse button is released the callback is invoked. Four steps during the execution of the application are shown in the following images. (The cursor is not shown.)