Developer forums (C::B DEVELOPMENT STRICTLY!) > Development

wxMenuItem Accelerator keys....

(1/2) > >>

darklordsatan:
I was trying to make the feature request on adding keyboard shotcuts for user defined tools... however I think thats out of my limits for now :cry:

From what Ive seen, all menus in c::b are defined in XRCs, where the accelerator key is defined in the tag "accel". For example:

--- Code: ---
<object class="wxMenuItem" name="idFileNew">
        <label>New File</label>
        <accel>Ctrl-N</accel>
        <help>Create a new source file</help>
</object>

--- End code ---


And thats it, pretty straightforward if you ask me, but I cant seem to find an example in c::b source on how to do this dynamically (since my bet is that all menus are created from XRCs... and the ones probably created dynamically dont have an accelerator key...)

My question is, do I have to hard code an event manager in order to implement such functionality in the user tools menu (this way would be wxwidgets related Im afraid), or can c::b provide me with some functions to do this? (This way it would be c::b related, aka  :D )

Thanks for your time

Ceniza:
Adding those keys is quite easy:


--- Code: ---  fileMenu->Append(FILE_CHANGE_DIR, _("Change default directory\tCtrl+D"));
--- End code ---


Search for wxMenu::Append in wxWidget's help :)

darklordsatan:
No I know, I even tried putting that when c::b created the menu item, and the most I reached was to add the ampersand (&) so, user defined tools could be accesed via menu accelerators (i.e navigating the menu with the keyboard), but not keyboard shortcuts... I tried appending the "\tctrl+key" but nothing happened: obviously you need to somehow register an event handler, the most I could see now that I remember was a Connect() function somewhere in c::b code but ...

rickg22:
Stan: The menus CAN work with the shortcut keys. Take a look at the old CVS sources. Also, in main.cpp (or was it app.cpp?) there's a shortcut key handler, I have a couple of extra-shorcuts there. If some keys don't work, they're probably overriden by some other menu.

darklordsatan:
Thanks son, main.cpp indeed shows how to create menu event handlers, will take a close look to it. Thanks again!

Navigation

[0] Message Index

[#] Next page

Go to full version