Nick U
Nick U

Reputation: 333

What is the best way to detect Copy (Ctrl+C) event in an IWpfTextView?

I am trying to detect a copy event in the text view and I have been researching the best way to do this. Is it to possibly hook into the StandardCommand Copy event somehow and detect it that way? Or is it possible to use the KeyProcessor(and simply detect Ctrl+C keypresses)?

My extension is currently implementing the IWpfTextViewCreationListener; is there a way to somehow get access to the KeyProcessor or StandardCommand from the IWpfTextView that the listener is passing to me? If so, can you post a code sample that demonstrates this?

Thanks! Nick

Upvotes: 0

Views: 175

Answers (1)

Noah Richards
Noah Richards

Reputation: 6867

You can listen for the Copy command (listening for ctrl-c won't work, as the shell turns it into a command before the editor sees the keypress event).

Take a look at the command filter template I wrote. You'll need to make sure you have references to the assemblies listed in this file.

Upvotes: 1

Related Questions