0

Is there any way to override mouse events connected with the Visual Studio IDE margin? I looked at the IMouseProcessorProvider interface, but it seems to work only with mouse events connected with the code editor window. For example:

public override void PostprocessMouseLeftButtonDown(MouseButtonEventArgs e)
{
    MyMethod();
}

MyMethod gets called only when I click the left button somewhere in the code editor window. I would like it to be called after clicking on a margin. How can I implement that?

Jakub Bielawa
  • 144
  • 2
  • 8
  • This is possible in theory, since Visual Studio is mostly WPF based. All you need to do is to get ahold of the WPF visual element (`UIElement`) for the margin, and then you can attach event listeners to the PreviewMouse* events. – Cameron Aug 28 '15 at 20:12
  • Thank you @Cameron. Thanks to you I found a solution - I was able to get the UIElement object of my custom glyph and then handle the mouse event I was interested in. – Jakub Bielawa Aug 29 '15 at 01:35

1 Answers1

0

I managed to find a solution - I was interested in calling MyMethod after clicking on my custom glyph on the margin, so I fetched the UIElement object representing the glyph (from my glyph factory class) and then I was able to implement MouseLeftButtonDown event.

Jakub Bielawa
  • 144
  • 2
  • 8
  • I found another solution - using [IGlyphMouseProcessorProvider](https://msdn.microsoft.com/en-us/library/microsoft.visualstudio.text.editor.iglyphmouseprocessorprovider.aspx) – Jakub Bielawa Sep 14 '15 at 14:11