I have a TabPanel where some specific styling of the "tab headers" are
needed. One style for the selected tab header, and another when the
mouse is over a tab header that is not selected. All this work
fine ... except that sometimes when changing tabs the mouseOver style
is not removed.

When adding tabs to the TabPanel I use the add(Widget w, Widget
tabWidget) method, where tabWidget is a custom version of Label:

---------------------------------------------------------------
  public class TabHeaderWidget extends Label {

    public TabHeaderWidget(String s) {
      super(s);

      // enable mouseOver/mouseOut events on the label
      sinkEvents(Event.ONMOUSEOVER|Event.ONMOUSEOUT);
    }

    @Override
    public void onBrowserEvent(Event event) {
      if (getParent().getStyleName().indexOf("gwt-TabBarItem-
selected") == -1) {
        // only do mouseover effect if the tab is NOT selected.

        switch (event.getTypeInt()) {
          case Event.ONMOUSEOVER:
            mouseOver();
            break;
          case Event.ONMOUSEOUT:
            mouseOut();
            break;
        }
      } else {
        // This was an early attempt to solve the problem :-/
        mouseOut();
      }
    }

    private void mouseOver() {
      // add style for text color
      addStyleName("tabhover");
    }

    private void mouseOut() {
      // remove style for text color
      removeStyleName("tabhover");
    }
  }
---------------------------------------------------------------

Any ideas as to why this should not _always_ work?

(btw, i'm using gwt1.5.2)
--~--~---------~--~----~------------~-------~--~----~
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