Copy Tooltip text from RichTextBox instead of Controls.image

349 Views Asked by At

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?

1

There are 1 best solutions below

0
On BEST ANSWER

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