Search in sources :

Example 1 with EventRemover

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;
}
Also used : MouseEvent(elemental.events.MouseEvent) EventRemover(elemental.events.EventRemover) Element(elemental.dom.Element) ArrayList(java.util.ArrayList) Event(elemental.events.Event) MouseEvent(elemental.events.MouseEvent) EventListener(elemental.events.EventListener) EventTarget(elemental.events.EventTarget)

Example 2 with EventRemover

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();
        }
    };
}
Also used : EventRemover(elemental.events.EventRemover) EventRemover(elemental.events.EventRemover)

Aggregations

EventRemover (elemental.events.EventRemover)2 Element (elemental.dom.Element)1 Event (elemental.events.Event)1 EventListener (elemental.events.EventListener)1 EventTarget (elemental.events.EventTarget)1 MouseEvent (elemental.events.MouseEvent)1 ArrayList (java.util.ArrayList)1