1

The problem

So I have a System.Windows.Controls.RichTextBox, which contains Paragraphs, containing Runs, containing either text or System.Windows.Controls.Image objects.

The images have Tooltips on them, describing what they do (not that you can see them when you hover in the RichTextBox.)

When I select and copy (ctrl-c) the contents of the RichTextBox, I want to copy the description of the image, rather than the image itself; and keep the rest of the text the same.

So, for example:

INFO: program is working!

would be copied as

"INFO: program is working!"

My ideas so far

I guess I would have to manually capture the event when text is copied from the RichTextBox (is there one?), and replace the contents of the clipboard by hand? Does the clipboard store the Tooltip information when the Image is copied? If not, is there any other way I could automatically get that information?

simonalexander2005
  • 4,338
  • 4
  • 48
  • 92
  • Text can be copied with the mouse, so it's more like you need to listen to Clipboard changes ([click](http://stackoverflow.com/q/6458030/1997232), [click](http://stackoverflow.com/q/3836169/1997232), doesn't looks good tbh) or completely wrap copying functionality (e.g. button `Copy all as text` or `Copy selected`), then you should have opportunity to go through selection of `RichTextBox` and replace images ([click](http://stackoverflow.com/q/4404516/1997232) ?). – Sinatr Jun 17 '15 at 09:55

1 Answers1

0

As the comment by @Sinatr says, the best way is to use the clipboard change event handlers and manually replace.

simonalexander2005
  • 4,338
  • 4
  • 48
  • 92