Search code examples
gwtmenumouseeventmenuitemmenubar

GWT: How to change Menubar image, on mouse events?


for my project I need to function my menu-bar like windows start button. How can i achieve this in GWT?

What i tried up to now is:

public class MyMenuBar extends Composite implements MouseDownHandler{

    @Override
    public void onMouseDown(MouseDownEvent event) {
        System.out.println("IMAGE CHANGED, using new safe html");
    }
    MenuBar myMenu;
    public MyMenuBar(){

        myMenu =  new MenuBar();
        myMenu.addItem(safeHtmlOfImage, popupMenuBar);

        this.addDomHandler(this, MouseDownEvent.getType());
        initWidget(myMenu);
    }
}

Issue is never onMouseDown(MouseDownEvent event) is invoked. Please help me, how can i achieve this. I am losing my second day with this thing. Tell me what ever you thinks about it...


Solution

  • I kind of solved issue, but nit think this is the actual solution: by setting the style code for the Menubar.

    .gwt-MenuItem
    {
    background-image: url("img/navigatorDeActive.png");
    }
    .gwt-MenuItem-selected
    {
    background-image: url("img/navigatorActive.png");
    }