Creating a selection tool

Selecting canvas graphics in GrafEdit is closely linked with the CursorTools framework. Depending on the type of tool that you use, a TSimpleMouseTool or a TDelegatingMouseTool, the CursorTools framework behaves slightly differently. See "Cursor tool handling" on page 96 for more information about the fundamental differences between these two types of cursor tools.

A delegating mouse tool requests that the selected view supplies an interactor, which it then starts. A simple mouse tool requests that the selected view supplies a target--in GrafEdit, the target is an MCanvasSelection. This selection is then passed to the pure virtual CreateInteractor function, which you implement in your simple mouse tool subclass. CreateInteractor returns an interactor which is then started (as in a delegating mouse tool). A delegating mouse tool essentially lets the view supply the interactor, whereas a simple mouse tool provides its own interactor.

In GrafEdit, TStandardArrowTool (a delegating mouse tool) is currently the only tool you use to make a selection. When you use this tool to click on the canvas view, the CursorTools framework calls TCanvasView::CreateToolInteractor, requesting an interactor. Here you instantiate and return the specified interactor, which is a TCanvasSelectionInteractor. Not only does this interactor manage your selection, but it can also manipulate (translate) a canvas graphic or selected set of graphics, if the user clicks and drags on a graphic (thus adding it to the selected set of graphics and moving it).

The following sections describe the TCanvasSelectionInteractor class to illustrate the code to manage the selection tool.


[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