PDA

View Full Version : Button icon change on mouseover



tib001
5 Dec 2011, 8:24 AM
[2.2.5]

Hi,
I have a problem on IE7 (and other one) when I'm trying to change an icon from my button on mouseOver event.
Here is the code :




AbstractImagePrototype iconDefault = ICON.default();
AbstractImagePrototype iconOver = ICON.over();

final Button b = new Button();
b.setText("test");
b.setIcon(iconDefault);
Listener<BaseEvent> mouseOver = new Listener< BaseEvent >() {


@Override
public void handleEvent( BaseEvent be )
{
b.setIcon( iconOver );
}
};
b.addListener( Events.OnMouseOver, mouseOver );

Listener<BaseEvent> mouseOut = new Listener< BaseEvent >() {


@Override
public void handleEvent( BaseEvent be )
{
b.setIcon( iconDefault );
}
};
b.addListener( Events.OnMouseOut, mouseOut );

RootPanel.get().add(b);




The problem happen when I roll over the icon (iconOver), I'm losing the focus and mouseOut event is fired.

I hope someone can help me;
Best regard,
tib!