CustomTextTool

CustomTextTool shows you how to write a text tool and interactor, and use menus and the Cursor Tools framework to use this new tool. The tool here is closely modeled on the EditableText class TSimpleTextTool.

Before reading this sample, review the Input sample MouseInteractors for more information on input system interactors.

Running the sample

Execute CustomTextToolSApp. The menu that appears provides the default tool and several instances of the default tool. Select a tool and drag over the text. When you release the mouse button, the tool colors the text or removes all color styles from the text, depending on the chosen tool.

Files and classes

TSampleTextTool is defined in TextToolSample.h and TextToolSample.C. It inherits from TSimpleMouseTool, and implements GetPaletteText, CreatePaletteGraphic, CreateCursorGraphic, and CreateInteractor. It instantiates and starts a TSampleTextToolInteractor, passing it a command and target to apply it to. TSampleTextTool also provides static member functions for creating a highlighter and an eraser graphic.

TSampleTextToolInteractor is defined in TextToolSample.h and TextToolSample.C, and inherits from TToolInteractor and MMouseEventHandler. It is used to establish a selection on its target, and applies a command to that selection when it finishes.


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