use of elemental.events.EventRemover in project che by eclipse.
the class Tooltip method attachToTargetElement.
/**
* Adds event handlers to the target element for the tooltip to show it on
* hover, and update position on mouse move.
*/
private List<EventRemover> attachToTargetElement() {
List<EventRemover> removers = new ArrayList<>();
for (int i = 0; i < targetElements.size(); i++) {
final Element targetElement = targetElements.get(i);
addPartner(targetElement);
removers.add(targetElement.addEventListener(Event.MOUSEOUT, new EventListener() {
@Override
public void handleEvent(Event evt) {
MouseEvent mouseEvt = (MouseEvent) evt;
EventTarget relatedTarget = mouseEvt.getRelatedTarget();
// Ignore the event unless we mouse completely out of the target element.
if (relatedTarget == null || !targetElement.contains((Node) relatedTarget)) {
cancelPendingShow();
}
}
}, false));
removers.add(targetElement.addEventListener(Event.MOUSEDOWN, new EventListener() {
@Override
public void handleEvent(Event evt) {
cancelPendingShow();
hide();
}
}, false));
}
return removers;
}
use of elemental.events.EventRemover in project che by eclipse.
the class MouseGestureListener method createAndAttach.
public static ListenerRegistrar.Remover createAndAttach(Element element, Callback callback) {
MouseGestureListener instance = new MouseGestureListener(callback);
final EventRemover eventRemover = element.addEventListener(Event.MOUSEDOWN, instance.captureListener, false);
return new ListenerRegistrar.Remover() {
@Override
public void remove() {
eventRemover.remove();
}
};
}
Aggregations