Issue
In the SDK sample CustomRibbon I saw a comment about the attribute ShortcutWindowTypes. But I did not know how it works.
Solution
As the SDK code explains: The ability of the attribute ShortcutWindowTypes of CommandHandlerPlugin is:
If you have defined a DockPanePlugin, you can specify that the Shortcut only applies when that window is active. Use the Id for the DockPanePlugin.
This attribute is just to specify if the shortcut can work or not.
Assume we have had a DockPanePlugin e.g. the SDK sample BasicDockPanePlugin. And in CommandHandlerPlugin, we define a command e.g.
[Command("ID_Button_3",
CanToggle = true,
Shortcut = "Shift+Z")]
In default, the shortcut can work anytime when we press “Shift+Z”. But if we add the attribute ShortcutWindowTypes
[Command("ID_Button_3",
CanToggle = true,
Shortcut = "Shift+Z",
ShortcutWindowTypes = "BasicDockPanePlugin.BasicDockPanePlugin.ADSK")]
Where: BasicDockPanePlugin.BasicDockPanePlugin.ADSK is the ID of the BasicDockPanePlugin.
What will happen?
- If the window of BasicDockPanePlugin is not displayed and not activate(Activate means it is being focused), the shortcut will NOT work anymore.
- If the window of BasicDockPanePlugin is displayed and activate, the shortcut will work as normal.
In a word, this attribute is to specify if the shortcut can work or not. In addition, when you set ShortcutWindowTypes, please make sure to set the correct ID (name) of the DockPanePlugin. Otherwise, the shortcut will still work.