CustomTextCommand
CustomTextCommand is a sample that shows you how to write a
derived class of a text command (in this case TReplaceTextCommand) and
put your command into a menu. It overrides
TReplaceTextCommand::HandleDoBegin to compute replacement text for the
currently selected text. It also illustrates one way to use
TTextChunkIterator.
Running the sample
Execute CustomTextCommandSApp. Select a few words of text and then
issue the Scramble Text command from the menu. The selected text is
replaced by the same text, but with the words in a different order.
Files and classes
TScrambleTextCommand, defined in ScrambleTextCommand.h and
ScrambleTextCommand.C, derives from TReplaceTextCommand and overrides
HandleDoBegin to initialize the text that replaces the current
selection. For fun, it extracts the current text, scrambles the
words, and uses that as the replacement text. It uses
TTextRepresentationReadEntry to access the text and TTextChunkIterator
to break the selection into TTextRanges.
CustomTextCommandMain.C shows how to use
MMomentaryTextCommandState and TCommandOn to add a
command to a menu.
Click the icon to mail questions or corrections about this material to Taligent personnel.
Copyright©1995 Taligent,Inc. All rights reserved.