use of elemental.events.EventTarget 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;
}
Aggregations