Mailing Lists: Apple Mailing Lists

Image of Mac OS face in stamp
 
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Changing menu shortcuts



Rolf Howarth wrote:

>I have a Swing application that uses a JMenuBar and set
>apple.laf.useScreenMenuBar so it appears in the Mac menu bar.
>Depending on context (which panels are shown etc.) I need to modify
>the menu, including reassigning keyboard shortcuts from an item in
>one menu to another using JMenuItem.setAccelerator().
>
>This all works, nearly, except for a refresh problem. If I go to the
>new menu the shortcut isn't shown unless I go to the old menu which
>used to have that shortcut first. Is there any way to force it to
>rebuild the Mac menu bar to resync it with the JMenuBar? (I already
>tried setting the menu bar to null and then resetting the actual menu
>bar, to no avail.)

I vaguely recall this problem coming up before, but I don't recall when, or
whether it was even about shortcuts.  Maybe search the list archives for
menu shortcut.

Or the problem may have appeared with hierarchical menus not changing, so
search for those keywords.

IIRC, the problem is that the screen menubar isn't being updated as the
JMenuBar elements change.  As I recall, the fix is to entirely replace one
menu-item with another one, which effectively "flushes the cache" so the
screen menubar gets changed.  Just changing attributes or properties on the
existing menu item doesn't get propagated through, so the "cache" isn't
flushed on "write", and you get what amounts to a cache-coherency bug.

And I think you have to remove the first shortcut before adding it to the
other item.

And I don't think setting the menubar to null does anything, because it's
not necessary to propagate menu item changes through for that.  It just
flips the menubar wholesale, rather than rebuilding any cached screen
menubar elements.

This is just a vague recollection ("cache incoherency of screen menubar" is
what sticks in my mind), so I could be wrong about any or all of the
details.

  -- GG


 _______________________________________________
Do not post admin requests to the list. They will be ignored.
Java-dev mailing list      (email@hidden)
Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/java-dev/email@hidden

This email sent to email@hidden



Visit the Apple Store online or at retail locations.
1-800-MY-APPLE

Contact Apple | Terms of Use | Privacy Policy

Copyright © 2007 Apple Inc. All rights reserved.