Quantcast
Channel: Visual Studio Integrate forum
Viewing all articles
Browse latest Browse all 4410

VSPackage: Acquiring the logical target of a command issued from a context menu

$
0
0

Hi folks,

I'm working on a VSPackage that adds an 'Add Address to Watch Window' command (similar to the built-in 'Add Watch') to the command window and the Locals, Autos, Watch, and code editor context menus. 

I've got the command installed in the appropriate menus and available to the command window and I'm able to retrieve command window parameter input by using an OleMenuCommand with a ParametersDescription of '$' and checking the OleMenuCmdEventArgs.InValue.

If the InValue is null, and I assume the command was issued by right-clicking on a word or selection in the code editor and selecting my command from the menu, I can retrieve the selected word from the active view of the IVsTextManager associated with my package. 

So, I can disambiguate the command window and code editor context menu, but how do I distinguish between the same command issued from the code editor context menu and the Locals or Autos window context menu?

This appears to be possible; the VsDbgCmdPlace.vsct that comes with the VS SDK places the same command (cmdidAddWatch) into each of the context menus. Additionally, VSIP logging claims that each of those commands are, in fact, the same cmdid.

Neither OleMenuCommand, OleMenuCmdEventArgs, nor IOleTarget appear to supply information about the UI element that opened the context menu, so I'm guessing there's some other command concept or interface I don't understand yet.

What am I missing?


Viewing all articles
Browse latest Browse all 4410

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>