# AcceleratorTable

**URL:** <https://www.ruby-forum.com/t/acceleratortable/177895>\
**Category:** wxRuby\
**Created:** [October 26, 2009, 12:44pm UTC](https://www.ruby-forum.com/t/acceleratortable/177895 "2009-10-26T12:44:40Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![biospank](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/b/f475e1/32.png) [@biospank](https://www.ruby-forum.com/u/biospank)\
**Post date:** [October 26, 2009, 12:44pm UTC](https://www.ruby-forum.com/t/acceleratortable/177895/1 "2009-10-26T12:44:40Z")

</div>

Hi all,

i’m using Wx::AcceleratorTable to shortcut function keys (F1, F2…)

Given the code:

acc\_table = Wx::AcceleratorTable[  
[Wx::MOD\_NORMAL, Wx::K\_F3, myBtn.get\_id()],  
[Wx::MOD\_ALT, Wx::K\_F4, myMnu.get\_id()]…]  
frame.accelerator\_table = acc\_table

the 3Â° param of Wx:AcceleratorEntry is an id identifing a menu item id  
or a  
commad id.

If i have a menu item or a button, i get the corresponding id into the  
third  
param and everything works as expected.

What to do if i have just a function (no button, neither menu item  
binded)?

How do i get the id to bind to?

Any help is greately appreciated.

thank you.

bio.

---

<div class="post-metadata">

**Author:** ![biospank](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/b/f475e1/32.png) [@biospank](https://www.ruby-forum.com/u/biospank)\
**Post date:** [October 27, 2009, 1:15pm UTC](https://www.ruby-forum.com/t/acceleratortable/177895/2 "2009-10-27T13:15:18Z")

</div>

hi Fabio

Fabio P. wrote:

> i’m using Wx::AcceleratorTable to shortcut function keys (F1, F2…)  
> …  
> What to do if i have just a function (no button, neither menu item  
> binded)?

An Accelerator Table is just that - a mapping of key presses that  
provide fast access to existing menu items or GUI controls. So it’s  
expected that there should be an ID to go with each.

However I expect that an accelerator entry would trigger an evt\_menu  
even if there wasn’t actually a real menu item in the Frame’s menus, if  
you wanted to “cheat”:

evt\_menu(SOME\_ARBITRARY\_ID, :the\_function)  
AcceleratorTable(…)

alex

---

<div class="post-metadata">

**Author:** ![biospank](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/b/f475e1/32.png) [@biospank](https://www.ruby-forum.com/u/biospank)\
**Post date:** [October 27, 2009, 3:15pm UTC](https://www.ruby-forum.com/t/acceleratortable/177895/3 "2009-10-27T15:15:55Z")

</div>

Thank you Alex,

However I expect that an accelerator entry would trigger an evt\_menu  
even if

> there wasn’t actually a real menu item in the Frame’s menus, if you wanted  
> to “cheat”:
> 
> evt\_menu(SOME\_ARBITRARY\_ID, :the\_function)  
> AcceleratorTable(…)

i’ll try to use your tip.

cheers.

bio.
