有没有办法使用普通的 ASCII 字符(如逗号)作为 wxWidgets 菜单加速器?
我想要一些菜单项来显示普通键的加速器,例如空格键或逗号键,但我不希望 wxWidgets 自己制作这些加速器(因为这样它们就不能在程序中的任何地方使用过,包括编辑框之类的地方)。
不幸的是,wxWidgets 坚持始终将其在该列中识别的任何内容放入其控制下的加速器中,并简单地删除其无法识别的任何内容。
我正在寻找某种方法来将任意文本放入加速器列(我认为不存在,我查看了源代码),或者获取用于菜单的加速器表,以便我可以自己修改一下(还没找到)。有人能指出我正确的方向吗?
I want a few menu entries that show accelerators that are normal keys, like the space-bar or comma key, but I don't want wxWidgets to make those accelerators itself (because then they can't be used anywhere in the program, including in things like edit boxes).
Unfortunately, wxWidgets insists on always making anything it recognizes in that column into an accelerator under its control, and simply erases anything it doesn't recognize.
I'm looking for some way to either put arbitrary text into the accelerator column (which I don't think exists, I've looked at the source code), or get 'hold of the accelerator table used for the menus so I can modify it myself (haven't found it yet). Can anyone point me in the right direction?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
你可以尝试wxKeyBinder。它允许您将热键绑定到命令(通常是菜单条目),轻松保存/加载/添加/删除/修改......
You can try wxKeyBinder. It allows you to bind hotkeys to commands (usually menu entries), save/load/add/remove/modify ... them easily
我找不到直接访问菜单加速键的方法,但修改加速菜单文本也可以。这是我想出的代码:
在头文件中:
在 cpp 文件中:
最简单的使用方法是像平常一样创建菜单栏,并放置所有加速键(包括有问题的加速键),然后创建一个其中的
accel_t
项目如下所示:它将识别并记录造成问题的加速键。最后,根据需要调用
remove
和restore
函数,以删除或恢复有问题的加速键。每当我打开需要进行标准编辑的窗口时,我都会通过传递到框架的消息来调用它们。I couldn't find a way to access the menu's accelerator keys directly, but modifying the accelerator menu text works just as well. Here's the code I came up with:
In a header file:
In a cpp file:
The easiest way to use it is to create your menu-bar as normal, with all accelerator keys (including the problematic ones) in place, then create an
accel_t
item from it something like this:It will identify and record the accelerator keys that pose problems. Finally, call the
remove
andrestore
functions as needed, to remove or restore the problematic accelerator keys. I'm calling them via messages passed to the frame whenever I open a window that needs to do standard editing.