Hello,
in my VSPackage (C#, VS2013) I want to add a command that is available via a shortcut only. The shortcut must be set by the user via Tools -> Options -> Environment -> Keyboard
I have added an entry in the "symbol" section of the vsct file and matched the value of the id with an entry in the PkgCmdIDList. The package has the ProvideAutoLoad attribute.
I tried the following:1. Adding no entry in the "button" section of the vsct file. This leads to the unfortunate result, that the command neither shows up in the options dialog (see above) nor in the menu, so it can not be executed at all.
2. Added an entry in the "button" section and addded the DefaultInvisible (in combination with the DynamicVisibility tag and without) tag to the button entry. This lets the command show in the options dialog, so I can add a shortcut and it hides the button from the menu. However, hitting the shortcut does not invoke the command - the event handler that was passed in the MenuCommand constructor is not called.
3. I removed the DefaultVisibility tag from the button and added the DynamicVisibility tag only. Then I changed the MenuCommand object into an OleMenuCommand object and added an event handler for the BeforeQueryStatus event. In that event handler I set the Visible property of the command to false. Now the shortcut works, however, the command button is also shown in the menu. The BeforeQueryStatus event handler is not called, until I chose the command button once in the menu. After that the event handler is called, the button is invisible and the shortcut still works.
3 is almost the solution except for the initial showing of the command button until I chose it once. Can anyone help?
Regards,
Marc