I received this question off-list, but thought it would be interesting
to everyone.
> Hello,
>
> I am running my program that uses control shortcut keys
> for the menu items I have declared in my menubar.
> However, I noticed something strange happening,
> shortcut commands can be over-written during runtime.
>
> example:
>
> I set my first menu item, in File Menu, to be the print
> command with "Ctrl P" as the shortcut. So, I would type
> "Alt F" to highlight the File menu, then, if I type
> another command like "Ctrl X", the first item in the list
> of menu items will change to be Ctrl X, in this case,
> "Ctrl P" is now "Ctrl X".
>
> Do anyone know how I can prevent this from happening?
> Your help will be greatly appreciated.
Interesting. I couldn''t find this in the wxWindows documentation, but I
have seen similar behavior before in the Anjuta programmers editor.
Basically, while any menu item is highlighted, hitting a key combination
sets the shortcut for that menu item. At least, it does on my Linux system.
You can see this in the minimal wxRuby sample. Bring up the File menu,
and make sure the Exit item is highlighted. If you use Alt-F, it will
already be highlighted. If you clicked on File, you need to hover over Exit.
Now press a key like F1, or Ctrl-Y. Whatever key you press will become
the shortcut for that item.
It can be a handy feature, but it could also surprise users. I don''t
see
any way to disable this feature, and I''m not sure what layer of
wxWindows is performing this magic. Or maybe it''s just a GTK thing.
Does
it happen on other platforms?
Kevin