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?
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_titem from it something like this:It will identify and record the accelerator keys that pose problems. Finally, call the
removeandrestorefunctions 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.