Reputation: 257
I want to implement the onMouseOut
method to hide the popup.
What is the difference b/w this two approaches..?
1. addMouseOutHandler
actionsPopup.addMouseOutHandler(new MouseOutHandler() {
@Override
public void onMouseOut(MouseOutEvent event) {
actionsPopup.hide();
}
});
});
2. addDOMHandler
actionsPopup.addDomHandler(new MouseOutHandler() {
@Override
public void onMouseOut(MouseOutEvent event) {
actionsPopup.hide();
}
});
}, MouseOutEvent.getType());
Upvotes: 1
Views: 393
Reputation: 430
There is no real difference. If you look into the GWT code of basic widgets (like FocusPanel) the implementation of the addMouseOutHandler just calls addDomHandler:
public HandlerRegistration addMouseOutHandler(MouseOutHandler handler) {
return addDomHandler(handler, MouseOutEvent.getType());
}
But by using the HasMouseOutHandlers interface, your code will have more flexibility. For example you can use the @UiHandler annotation. Or you can also see your widget like a 'HasMouseOutHandlers' instance in order to group some treatments. By the way, in the signature of your object, you indicate clearly to others developers that your object can receive this type of event.
Upvotes: 3