# Menu Bar KeyBoard Shortcuts

**URL:** <https://www.ruby-forum.com/t/menu-bar-keyboard-shortcuts/123604>\
**Category:** wxRuby\
**Created:** [December 19, 2007, 2:30am UTC](https://www.ruby-forum.com/t/menu-bar-keyboard-shortcuts/123604 "2007-12-19T02:30:18Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Bill\_K](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/b/0ea827/32.png) [@Bill\_K](https://www.ruby-forum.com/u/Bill_K)\
**Post date:** [December 19, 2007, 2:30am UTC](https://www.ruby-forum.com/t/menu-bar-keyboard-shortcuts/123604/1 "2007-12-19T02:30:18Z")

</div>

Hello,

I’m trying to use a wxMenuBar from XRC built with DialogBlocks on  
Windows.

My first example had the menu being called from the Frame because I  
couldn’t figure out  
how to call the menu from my XRC. Shortcuts worked nicely.

Example 1:  
menu.append(Wx::ID\_EXIT, “E&xit\tAlt-X”, “Quit this program”)

tool.append(Wx::ID\_PHOTO, “&MS Picture Manager\tAlt-B”, “MS Picture  
Manager”)

Now that I’ve figured this out, I lost the ability to have my Keyboard  
shortcuts as a parameter.

Example 2 :  
@menubar = self.get\_menu\_bar.find\_menu(‘ID\_MENUBAR1’) # This  
only accepts 1 argument  
@menu\_quit = self.get\_menu\_bar.find\_menu\_item(“File”,“Quit”) #  
This only accepts 2 arguments

or

evt\_menu(self.get\_menu\_bar.find\_menu\_item(“Tools”,“MS Picture  
Manager”)) do  
open\_ex  
end

Is there a way to use the Keyboard Shortcuts with XRIC?

Thank you,  
Bill

---

<div class="post-metadata">

**Author:** ![Bill\_K](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/b/0ea827/32.png) [@Bill\_K](https://www.ruby-forum.com/u/Bill_K)\
**Post date:** [December 20, 2007, 2:54am UTC](https://www.ruby-forum.com/t/menu-bar-keyboard-shortcuts/123604/2 "2007-12-20T02:54:04Z")

</div>

Hi Bill

Bill K wrote:

> I’m trying to use a wxMenuBar from XRC built with DialogBlocks on Windows.  
> …  
> tool.append(Wx::ID\_PHOTO, “&MS Picture Manager\tAlt-B”, “MS Picture  
> Manager”)

…

> Is there a way to use the Keyboard Shortcuts with XRIC?

You can create keyboard shortcuts in XRC by adding, for example,  
"\tCtrl+x"at the end of the label, in the same way as you’d set a  
keyboard shortcut if creating the menu directly in Ruby. I just tried  
this out in DialogBlocks on OS X and it seems to work correctly, and the  
sample project includes a frame with this in it.

Let me know if this isn’t working, or if I’ve not understood your  
question.

cheers  
alex
