Shortcut keys for menu items?

How do I achieve this?

Can’t see any examples

I have a top level MenuItem and want ALT-B to open it

Thanks.

Hi!

What do you need this for? There is no easy way to open the menu, but you could create shortcuts for the menuitem-actions instead, like save. Would this solve your problem?

So the menu can be used like almost any menu from the last 20 years.

e.g. http://en.wikipedia.org/wiki/Keyboard_shortcut

I have no idea whether actions would help. That’s why I was asking. I couldn’t see any examples of this
and was surprised as it is such a common mechanism.

http://www.homeandlearn.co.uk/NET/nets4p4.html

As you can see, in VB it is as simple as adding & to menu item name.

Hi!

You can create a shortcut for a save-function for example:

        ShortcutListener saveShortcut = new ShortcutListener("saveshortcut", KeyCode.S,
                ModifierKey.CTRL) {

            @Override
            public void handleAction(Object sender, Object target) {
                saveFile();
            }
        };

And you can call the same save-function in your MenuItem command:

[code]
Command savecommand = new Command() {

        @Override
        public void menuSelected(MenuItem selectedItem) {
            saveFile();
        }

    };

    MenuItem save = file.addItem("save", savecommand);

[/code]You need to add the ShortcutListener to your layout or view:

layout.addShortCutListener(saveShortcut); Hope this helps!