Does anybody know how to capture a click on a TextMarker in an IWpfTextView? I want to have this functionality in the XML editor, to allow CTRL+Click on certain nodes. The specific nodes can be highlighted now, but there is not an “OnClick” event on a Textmarker.
See also:
http://msdn.microsoft.com/en-us/library/microsoft.visualstudio.text.tagging.textmarkertag.aspx
There’s no event on a TextMarker, you are correct. What you want to do is implement and MEF export an IMouseProcessor, and in the appropriate methods see if you’re within a span you care about. There’s a class
MouseProcessorBaseyou can derive from to make your implementation a bit less irritating.Noah Richards’ GoToDef sample which implements Ctrl+Click in a very similar way like you are trying to do here. The code is up at https://github.com/NoahRic/GoToDef. I’d strongly recommend you take a look at it.