如何扩展.js文件的vs2010编辑器上下文菜单?
我有一个带有几个命令的VS2010 VSIP软件包,这些命令已添加到javascript编辑器的上下文菜单中,并且我正在使用
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>
但是它仅适用于C#文件,如何使其适用于.js文件?
but it work only C# file,how to make it work for .js file?
HTML/CSS/JS代码编辑器实际显示的上下文菜单与主代码编辑器不同.不幸的是,这些上下文菜单的Guid/id对没有在Visual Studio SDK中发布或定义.
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.
但是,有一个调试钩子(自VS 2005 SP1起),它使您可以识别几乎所有感兴趣的菜单项的Guid/ID.请参见
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.
使用该贴子中描述的技术,如果我在Javascript编辑器中按CTRL + SHIFT + RIGHTCLICK,则会出现以下对话框:
Using the technique described in that post, if I CTRL+SHIFT+RIGHTCLICK in the Javascript editor, I get the following dialog:
在< Symbols>中VSCT文件的部分"中,我可以输入以下内容:
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>
然后,只需为该Guid/ID做父母即可.
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>