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

Custom Editor Code Behind Keybinding Function Key Not Working - Question 1

$
0
0

This is the 1st of 2 closely related questions (2nd one is here).

I have a custom editor. It stores XML in a file with custom extension. When the user opens it in Solution Explorer, it opens the custom editor UI.

I want it to have the "View Code" and "View Designer" behavior that other designers have.

I have set up the context menus for the file extension in Solution Explorer and they are firing the event handlers successfully.  From there I can open the file with Dte.ItemOperations.OpenFile and specify vsViewKindCode or vsViewKindPrimary.

So far so good, but I want it to work like other such editors that use F7 and Shift+F7 to switch back and forth between code view.

I created the following KeyBindings in the VSCT file.

<KeyBindings><!--For context menu in Solution Explorer--><KeyBinding guid="guidMyEditorCmdSet" id="cmdidFileMenuViewCode" editor="guidVSStd97" key1="VK_F7" /><KeyBinding guid="guidMyEditorCmdSet" id="cmdidFileMenuViewDesigner" editor="guidVSStd97" key1="VK_F7" mod1="Shift" /><!--For when custom editor is open either as designer or as code behind--><KeyBinding guid="guidMyEditorCmdSet" id="cmdidFileMenuViewCode" editor="guidMyEditorEditorFactory" key1="VK_F7" /><KeyBinding guid="guidMyEditorCmdSet" id="cmdidFileMenuViewDesigner" editor="guidMyEditorEditorFactory" key1="VK_F7" mod1="Shift" /></KeyBindings>


For context menu in solution explorer (1st two KeyBinding entries), it is not showing the shortcut key on the context menu.  If I change key1="VK_F7" to key1="3", it displays the context menu (for the key 3, which if course is not what I want).  Having read questions like this, I suspect editor="guidVSStd97" is at the wrong scope.  In fact I know it is because when I try key1="3", it works regardless of whether the file is selected in solution explorer (scope too broad/global).

What is the appropriate value (editor="?") so that the function key only applies when the file is selected in Solution Explorer, and the shortcut appears in the context menu (similarly to other editors that switch back and forth to code behind)?

Or if I'm wrong about this depending on the editor value, how do I get it to work?



Viewing all articles
Browse latest Browse all 4410

Trending Articles