Question

I'm writing a (very) simple Visual Studio addin. Two things that would make it work nicer are:

  1. A context menu.

  2. Knowing the caret position in the current document (so I can inject text at that position).

Any ideas?

Was it helpful?

Solution

To add a context menu to your addin, you create a CommandBarPopup from:

_applicationObject.CommandBars["Code Window"]

You can view a sample here.

The second part of your question is a little simpler, the current "selection" (or insertion point) is handled by:

(TextSelection)_applicationObject.ActiveDocument.Selection

"_applicationObject" is an instance the DTE Application object created by the add-in project wizard.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top