Author Topic: wxMenuItem Accelerator keys....  (Read 6929 times)

Offline darklordsatan

  • Almost regular
  • **
  • Posts: 132
    • http://eviltrend.sf.net
wxMenuItem Accelerator keys....
« on: July 15, 2005, 07:33:54 am »
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: [Select]

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


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

Offline Ceniza

  • Developer
  • Lives here!
  • *****
  • Posts: 1442
    • CenizaSOFT
wxMenuItem Accelerator keys....
« Reply #1 on: July 15, 2005, 07:42:41 am »
Adding those keys is quite easy:

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

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

Offline darklordsatan

  • Almost regular
  • **
  • Posts: 132
    • http://eviltrend.sf.net
wxMenuItem Accelerator keys....
« Reply #2 on: July 15, 2005, 08:14:51 am »
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 ...

Offline rickg22

  • Lives here!
  • ****
  • Posts: 2283
wxMenuItem Accelerator keys....
« Reply #3 on: July 15, 2005, 08:37:00 am »
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.

Offline darklordsatan

  • Almost regular
  • **
  • Posts: 132
    • http://eviltrend.sf.net
wxMenuItem Accelerator keys....
« Reply #4 on: July 15, 2005, 08:48:24 am »
Thanks son, main.cpp indeed shows how to create menu event handlers, will take a close look to it. Thanks again!

Offline mandrav

  • Project Leader
  • Administrator
  • Lives here!
  • *****
  • Posts: 4291
    • Code::Blocks IDE
wxMenuItem Accelerator keys....
« Reply #5 on: July 15, 2005, 09:10:58 am »
If you want to add customizable shortcuts for the menus in C::B, check out KeyBinder from wxCode. It's perfect for the job. I planned on adding it some time, but if you think you 're up to the task you 're free to do it yourself ;)

Yiannis.
Be patient!
This bug will be fixed soon...

Offline darklordsatan

  • Almost regular
  • **
  • Posts: 132
    • http://eviltrend.sf.net
wxMenuItem Accelerator keys....
« Reply #6 on: July 15, 2005, 09:49:43 am »
Quote from: mandrav
I planned on adding it some time, but if you think you 're up to the task you 're free to do it yourself ;)


mmm, nothing like the fresh smell of a plugin in the morning... Wait! I shouldnt reveal my evil plans...