Skip to main content
Known Participant
January 17, 2008
Question

Getting the currently selected text

  • January 17, 2008
  • 3 replies
  • 455 views
Hi,

this is probably a newbie question but i don't seem to find the relevant info.
How can i obtain a refernce to the selected text and have it returned as a PMString or WideString?

I tried ITextEditSuite, ITextTarget but found no methods à la GetSelectedText() or something.

Thanks in advance!
Regrads,
Florian.
This topic has been closed for replies.

3 replies

Known Participant
January 18, 2008
Thanks guys, got it to work!
Known Participant
January 18, 2008
First,you need to implement a suite to get the ITextFocus interface;
Second,by this interface you can get the text index and the text model;
Finally,as Dirk said use the IComposeScanner::CopyText to get the selected text.
Inspiring
January 17, 2008
The problem is the concept of "having the selection returned". This is undesired..verboten with the selection architecture and will be punished with copy-pasting of 100 AddIn declarations into various applicable suite bosses.

Seriously, can you rephrase your approach to "feed it into some operation" ? Then this "some operation" is either implemented by any related suite, or it is your turn to write a new suite.

The "concrete" side of the suite can refer to the ITextTarget to determine the selection (you've gotten pretty close), and use the interfaces on the text model kTextStoryBoss e.g. to retrieve it. Have a look at IComposeScanner::CopyText :)

Dirk