justanothercoder
justanothercoder

Reputation: 234

How to override events for extended widgets in gwt?

How would I override events e.g. OnmouseOver, OnMouseOut in extended widgets?

I am trying to extend the Anchor widget and want to set a certain stylename from my CSS.

Upvotes: 0

Views: 151

Answers (1)

Hilbrand Bouwkamp
Hilbrand Bouwkamp

Reputation: 13519

In this case you could add handlers in you constructor via addMouseOverHandler and addMouseOutHandler and the handlers add/remove your stylenames.

Another option is to override the OnBrowserEvent(Event event) method on catch the mouse over and mouse out events.

However, mouse out events won't work perfect in all browsers. Sometimes the mouse out event is not triggered on the widget and you're style will stay on the widget. If you want to set style on a widget you could also add a yourstylename:hover in you're style sheet, such that you let the browser do the work of adding and removing the stylenames.

Upvotes: 2

Related Questions