可以为使用 DynamicItemStart 的 Visual Studio 2012 扩展包命令分配键盘快捷键吗? [英] Can one assign keyboard shortcuts to Visual Studio 2012 extensibility package commands that use DynamicItemStart?

查看:42
本文介绍了可以为使用 DynamicItemStart 的 Visual Studio 2012 扩展包命令分配键盘快捷键吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个 VS2012 扩展包,它使用 DynamicItemStart 命令标志将命令添加到菜单,如 MSDN 上所述.这些命令的工作方式有点像内置的外部工具工具,因此确切的设置由插件用户配置,而不是由我定义.DynamicItemStart 命令似乎最适合于此.

I've got a VS2012 extensibility package that adds commands to a menu using the DynamicItemStart command flag, as described on MSDN. These commands work a bit like the inbuilt External Tools facility, so the exact set is configured by the addin user, rather than being defined by me. A DynamicItemStart command seems most suitable for this.

根据示例,我添加了一堆项目,隐藏它们,然后使用 BeforeQueryStatus 回调控制可见性.这一切似乎都在起作用:菜单项的显示完全符合我的预期,您可以通过用鼠标单击它们来调用它们.我的包也有一个固定命令,它也有效.

As per the example, I add a bunch of items, hide them, and then control the visibility using the BeforeQueryStatus callback. This all appears to be working: the menu items appear exactly as I'd expect, and you can invoke them by clicking them with the mouse. My package also has one fixed command, and that works too.

我的非动态命令也出现在工具|选项、键盘部分的命令列表中,因此您可以为其创建键盘快捷键.(您也可以从似乎使用相同列表的立即窗口调用它.)但是我的动态命令没有出现!我期待它们作为某种自动生成的列表出现,例如 Tools.ExternalCommand.

My non-dynamic command also appears in the commands list in Tools|Options, Keyboard section, so you can make a keyboard shortcut for it. (You can also invoke it from the Immediate window, which appears to use the same list.) But my dynamic commands don't appear! I was expecting them to turn up as some kind of auto-generated list, like Tools.ExternalCommand.

DynamicItemStart 命令不能以这种方式调用吗?

Are DynamicItemStart commands just not invokable in this way?

推荐答案

万一遇到这个问题的其他人发现这个问题...

In case the other person with this problem finds this question...

DynamicItemStart 命令似乎没有名称,据我所知.文档说它们用于 MRU 或窗口列表,所以也许没有人认为有人需要命名它们.

DynamicItemStart commands don't appear to have names, as far as I can figure out. The docs say they're for MRU or window lists, so maybe nobody thought anybody would need to name them.

因此,出于我的目的,我只创建了 100 个占位符命令 (Command00 ... Command99),设置了 DynamicVisibilityTextChanges 每个命令标志.(我现在有一个 1,237 行的 VSCT 文件.)

So, for my purposes, I just created 100 placeholder commands (Command00 ... Command99), setting the DynamicVisibility and TextChanges command flags for each. (I now have a 1,237-line VSCT file.)

然后在运行时我使用 BeforeQueryStatus 回调来隐藏未使用的项目,显示使用的项目,并为菜单设置它们的(用户分配的)标题.而且我的 UI 会小心地显示哪个命令对应于每个分配的操作,并保持映射完整,因此用户在为每个操作分配键盘快捷键时知道要使用 100 个命令名称中的哪个.

Then at runtime I use the BeforeQueryStatus callback to hide the unused items, show the used items, and set their (user-assigned) captions for the menu. And my UI is careful to show which command corresponds to each assigned action, and keep the mapping intact, so the user knows which of the 100 command names to use when assigning a keyboard shortcuts for each of their actions.

这并不理想,而且在 Visual Studio 中是一个令人讨厌的限制.但看起来它会正常工作.

This is hardly ideal, and a bit of an annoying limitation in Visual Studio. But it looks like it's going to work adequately.

这篇关于可以为使用 DynamicItemStart 的 Visual Studio 2012 扩展包命令分配键盘快捷键吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆