Class architecture

As shown in Figure 16, TCanvasInteractor derives from a series of Document framework abstract base classes.


The TInteractor::SetDone function is called by derived classes when they want to end interaction (cease getting events). SetDone reads a particular mouse input as indicating the end of an interaction. A double click indicates the end of a series of mouse clicks in TCanvasMulticlickInteractor, and a mouse-up event indicates the end of a drag operation in TCanvasDragInteractor.

MMouseEventHandler mixes in functions that define the actions to take when a mouse-up, mouse-down, or mouse-move event is detected.

As a TToolInteractor derived class, TCanvasInteractor works with cursor tools because TToolInteractor provides the mechanism for doing commands.

The TCanvasInteractor functions and derived classes are shown in Figure 17. The TCanvasInteractor functions provide an interface for all canvas interactors that includes functions for managing points and key modifiers. A key modifier is a key on the user's keyboard that is held down while moving the mouse to accomplish a multiclick or drag operation. The derived classes provide an interface for the two most common canvas interaction behaviors, multiclick
and drag.


TCanvasMulticlickInteractor and TCanvasDragInteractor field mouse events by overriding the MMouseEventHandler functions (MouseUp, MouseDown, MouseMoved) to decide when to record significant points, save the modifier key state, and draw interaction feedback like rubber band lines. These two classes use this information by calling StartInteraction, ContinueInteraction, and EndInteraction. To end an interaction, the TCanvasInteractor derived classes call SetDone and then EndInteraction.

TCanvasMulticlickInteractor and TCanvasDragInteractor connect the MouseUp, MouseDown, and MouseMoved functions to the canvas interactor functions for recording points, remembering the modifier keys, and controlling the derived classes.

Multiclick interaction

The first time the mouse button is pressed, TCanvasMultiClickInteractor records the location of the mouse-down event, sets the corresponding modifier keys, and calls StartInteraction. Each subsequent time the mouse button is pressed, TCanvasMulticlickInteractor does the same thing, but calls ContinueInteraction instead of StartInteraction. When the mouse button is pressed with a click-count that is greater than one (for example, a double click), it does the same thing, but calls EndInteraction and SetDone.

TCanvasPolylineMulticlickInteractor and derived classes (shown in Figure 18) are described under "Interaction feedback" on page 90. The TCanvasPolylineMulticlickInteractor derived classes draw a polyline and a curve using those feedback styles.


Drag Interaction

When the mouse button is pressed, TCanvasDragInteractor records the location of the mouse-down event, sets the corresponding modifier keys, and calls StartInteraction. Thereafter, while the mouse button remains pressed, each time the mouse is moved it records the location of the mouse-moved event and calls ContinueInteraction.

NOTE TCanvasDragInteractor does not set the modifier key during the drag.

When the mouse button is released, TCanvasDragInteractor records the location of the mouse-up event, sets the corresponding modifier keys, and calls EndInteraction and SetDone.

The TCanvasDragInteractor and derived classes (shown in Figure 19) feedback styles are described under "Interaction feedback" on page 90.


TCanvasLineCreationInteractor draws a line using the feedback style of TCanvasLineDragInteractor.

TCanvasSelectionIntereactor selects a canvas graphic using the feedback style of TCanvasRectDragInteractor.

TBasicCanvasGraphicCreationIntereactor draws a basic canvas graphic using the feedback style of TCanvasRectDragInteractor.

TCanvasCurveCreationInteractor draws a curve using the feedback style of TCanvasPolylineDragInteractor.


[Contents] [Previous] [Next]
Click the icon to mail questions or corrections about this material to Taligent personnel.
Copyright©1995 Taligent,Inc. All rights reserved.

Generated with WebMaker