How to Extending vs2010 editor context menu for .js file?
Asked Answered
H

1

3

I have a VS2010 VSIP package with several commands,Those commands are added to the javascript editor's context menu,and i am using

  <Group guid="guidPrettyJsCmdSet" id="ContextMenuGroup" priority="0x0600">
       <Parent guid="guidSHLMainMenu" id="IDM_VS_CTXT_CODEWIN"/>
  </Group>

but it work only C# file,how to make it work for .js file?

Heuristic answered 9/9, 2010 at 1:13 Comment(0)
D
12

The HTML/CSS/JS code editors actually show different context menus than the main code editor. Unfortunately, the Guid/ID pairs for these context menus aren't published or defined in the Visual Studio SDK.

However, there is a debug hook (since VS 2005 SP1) that lets you identify the Guid/ID of almost any menu item you could be interested in. See this blog post for how to do that.

Using the technique described in that post, if I CTRL+SHIFT+RIGHTCLICK in the Javascript editor, I get the following dialog:

alt text

In the <Symbols> section of my VSCT file, I can put the following:

<GuidSymbol name="htmlEditorCommandSet" value="{D7E8C5E1-BDB8-11D0-9C88-0000F8040A53}">
  <IDSymbol name="jsContextMenu" value="0x0034"/>  <!-- 52 in hex is 0x0034 -->
</GuidSymbol>

Then, it's just a matter of parenting to that Guid/ID:

  <Group guid="guidPrettyJsCmdSet" id="ContextMenuGroup" priority="0x0600">
    <Parent guid="htmlEditorCommandSet" id="jsContextMenu"/>
  </Group>
Delusive answered 9/9, 2010 at 20:42 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.