In searching through the source code, I decided on the following work-
around when instantiating a MenuBar.  Unfortunately, it doesn't handle
every scenario, but it gets most of them right.

MenuBar bar = new MenuBar() {
        @Override
        public void onBrowserEvent(Event event) {
                super.onBrowserEvent(event);
                if (DOM.eventGetType(event) == Event.ONMOUSEOUT) {
                        Element barEle = getElement();
                        Element outEle = DOM.eventGetFromElement(event);
                        Element toEle = DOM.eventGetToElement(event);
                        if (DOM.isOrHasChild(barEle, outEle) && 
!DOM.isOrHasChild(barEle,
toEle)) {
                                //      Focus has shifted off of the MenuBar.  
But is it now on a sub-
menu?
                                boolean onSubMenu = false;
                                for (MenuItem mi : this.getItems()) {
                                        MenuBar subMenu = mi.getSubMenu();
                                        Widget parent = subMenu == null ? null 
: subMenu.getParent();
                                        Element parEle = parent == null ? null 
: parent.getElement();
                                        if ((parEle != null) && 
(DOM.isOrHasChild(parEle, toEle))) {
                                                onSubMenu = true;
                                                break;
                                        }
                                }
                                if (!onSubMenu) {
                                        MenuItem mi = getSelectedItem();
                                        if (mi != null) {
                                                
mi.removeStyleDependentName("selected");
                                        }
                                }
                        }
                }
        }
        @Override
        public void onPopupClosed(PopupPanel sender, boolean autoClosed) {
                MenuItem mi = getSelectedItem();
                if (mi != null) {
                        //      Is the closed Popup the currently selected menu 
item?
                        if (mi.getSubMenu() == sender.getWidget()) {
                                mi.removeStyleDependentName("selected");
                        }
                }
                super.onPopupClosed(sender, autoClosed);
        }
};


Hope this helps someone else,

john...

PS.  Please let me know if this is going to be fixed in a future
release, or let me know what I can do to get it on that list.


On Dec 30, 10:54 am, John Fowler <john_c_fow...@yahoo.com> wrote:
> Does anyone know if this is a defect to be corrected, or if there is a
> work-around for this?
>
> For clarity, I'll describe the scenario fully according to two cases:
>
> 1)  When a menu bar is set to automatically open its sub-menus,
> MenuBar.setAutoOpen(true), and the user does not select a menu item,
> the menus do not close until the user clicks outside of the menu bar
> area.  That functionality is _correct_.  HOWEVER, once the sub-menu
> does close in response to a click, the header text/icon on the menu
> bar for that sub-menu stays highlighted with its hover style.  That is
> _not_ correct.
>
> 2)  When the menu bar is not set to automatically open it's sub-menus
> (default operation), and the user merely moves their mouse over the
> menu bar, the menu items hovered over will highlight.  However, if the
> user does not click any menu item, but moves the mouse off the menu
> bar, the last hovered item will remain highlighted.  That is not
> correct GUI behavior.
>
> I know of no application which functions in this manner, so I believe
> this should rightly be called a defect.
>
> Can anyone tell me if this has already been identified, or how I can
> work around it?
>
> john...
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"Google Web Toolkit" group.
To post to this group, send email to Google-Web-Toolkit@googlegroups.com
To unsubscribe from this group, send email to 
google-web-toolkit+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/Google-Web-Toolkit?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to