Here's an example of how you might activate the menu in a key press handler. 
When the user presses Alt-Space and the menu is not currently active, the first 
menu is shown and the user can navigate the menu via keyboard:

        Frame frame = (Frame)component;
        MenuBar menuBar = frame.getMenuBar();
        
        if (menuBar != null
            && keyCode == Keyboard.KeyCode.SPACE
            && Keyboard.isPressed(Keyboard.Modifier.ALT)) {
            MenuBar.Item activeItem = menuBar.getActiveItem();
            MenuBar.ItemSequence items = menuBar.getItems();
            
            if (activeItem == null
                && items.getLength() > 0) {
                items.get(0).setActive(true);
            }
        }

I actually implemented this in TerraFrameSkin#keyPressed() - if you think it is 
useful, I can commit it.

G

On Nov 5, 2010, at 4:17 PM, Greg Brown wrote:

> What you are describing is called a mnemonic:
> 
>   http://msdn.microsoft.com/en-us/library/bb158536.aspx
> 
> There are no current plans to implement such a feature. However, it should be 
> easy enough to wire up a key event listener that will open the menu bar - the 
> user could use the arrow or tab keys to navigate the menu system from there.
> 
> On Nov 5, 2010, at 4:10 PM, ocean ocean wrote:
> 
>> Not sure what you mean. I can create global keyboard shortcuts as described 
>> in the MenuBars tutorial. I mean ability to press 'Alt' and have that 
>> underline top-level menus, then press 'F' to pop open the File menu. So 
>> users can navigate the menu structure without reaching for the mouse. Just 
>> curious if this is something planned or not.
>> 
>> On Fri, Nov 5, 2010 at 4:06 PM, Greg Brown <[email protected]> wrote:
>> Windows-style mnemonics are not supported, but Mac-style keyboard shortcuts 
>> are. See the Menu Bars tutorial for more info.
>> 
>> On Nov 5, 2010, at 3:50 PM, ocean ocean wrote:
>> 
>>> I understand according to ( 
>>> http://mail-archives.apache.org/mod_mbox/pivot-user/201010.mbox/%[email protected]%3e
>>>  ) menu accelerators aren't built in yet. Keyboard navigability is pretty 
>>> important for my apps so I was just curious if this was in the plans...
>> 
>> 
> 

Reply via email to