views:

112

answers:

1

I'm writing an add-on (by the format of VSPackage) for Visual Studio. One of the designed feature is: when user left-clicks in the area of text editor or presses up or down key to move to a new line, the add-on can capture this event and then do something (It's similar as the "VA Outline" feature in Visual Assist, when you clicks to a new line, the corresponding element will be highlighted in VA Outline tool window).

The problem I meet is: I can't find any API in Visual Studio Shell or other SDK that supports the Mouse-level event (The Envdte80 namespace supplies an event named "TextDocumentKeyPressEvents" which can be used for keyboard-level event). Does somebody get a solution to this? Many thanks in advance:-)

A: 

There is no direct way to do so in Visual Studio extensibility. But you can use native WinAPI (from C++ or C# extensibility package) to set a global mouse hook - this will give you ability to intercept mouse clicks. You can than filter click, get caret position in text editor etc from within your extensibility package.

Eye of Hell
Eye of Hell, you wrote: *>You can then get caret position in text editor*Do you have an API to propose to get a EnvDTE.TextPoint from a [X,Y] on screen mouse coordinate?
Patrick Smacchia - NDepend dev