4

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?

Mihai Limbășan
  • 64,368
  • 4
  • 48
  • 59
Giovanni Galbo
  • 12,963
  • 13
  • 59
  • 78

1 Answers1

8

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.

Jim H.
  • 5,539
  • 1
  • 24
  • 23