Search in sources :

Example 16 with EventListener

use of com.google.gwt.user.client.EventListener in project rstudio by rstudio.

the class ChunkContextToolbar method initOptions.

// Private methods ---------------------------------------------------------
private void initOptions(boolean dark) {
    options_.setResource(new ImageResource2x(dark ? RES.chunkOptionsDark2x() : RES.chunkOptionsLight2x()));
    DOM.sinkEvents(options_.getElement(), Event.ONCLICK);
    DOM.setEventListener(options_.getElement(), new EventListener() {

        @Override
        public void onBrowserEvent(Event event) {
            if (DOM.eventGetType(event) == Event.ONCLICK) {
                host_.showOptions(event.getClientX(), event.getClientY());
            }
        }
    });
}
Also used : ImageResource2x(org.rstudio.core.client.resources.ImageResource2x) Event(com.google.gwt.user.client.Event) EventListener(com.google.gwt.user.client.EventListener)

Example 17 with EventListener

use of com.google.gwt.user.client.EventListener in project gerrit by GerritCodeReview.

the class SideBySideChunkManager method focus.

private static void focus(NativeEvent event, DisplaySide side) {
    Element e = Element.as(event.getEventTarget());
    for (e = DOM.getParent(e); e != null; e = DOM.getParent(e)) {
        EventListener l = DOM.getEventListener(e);
        if (l instanceof SideBySide) {
            ((SideBySide) l).getCmFromSide(side).focus();
            event.stopPropagation();
        }
    }
}
Also used : Element(com.google.gwt.dom.client.Element) EventListener(com.google.gwt.user.client.EventListener)

Example 18 with EventListener

use of com.google.gwt.user.client.EventListener in project gwt-test-utils by gwt-test-utils.

the class DOMImplPatcher method dispatchEvent.

@PatchMethod
static void dispatchEvent(Object domImpl, Element target, NativeEvent evt) {
    EventListener listener = DOM.getEventListener(target);
    if (listener != null && evt instanceof Event) {
        listener.onBrowserEvent((Event) evt);
    }
    // dispatch to parent if needed
    boolean propagationStopped = JavaScriptObjects.getBoolean(evt, JsoProperties.EVENT_IS_STOPPED);
    if (target.getParentElement() != null && propagationStopped) {
        target.getParentElement().dispatchEvent(evt);
    }
}
Also used : Event(com.google.gwt.user.client.Event) EventListener(com.google.gwt.user.client.EventListener) PatchMethod(com.googlecode.gwt.test.patchers.PatchMethod)

Example 19 with EventListener

use of com.google.gwt.user.client.EventListener in project gwt-test-utils by gwt-test-utils.

the class Browser method click.

/**
 * Simulates a click event.
 *
 * @param target
 *            The targeted Element.
 */
public static void click(Element target) {
    EventListener eventListener = getEventListener(target);
    click((IsWidget) eventListener, target);
}
Also used : EventListener(com.google.gwt.user.client.EventListener)

Example 20 with EventListener

use of com.google.gwt.user.client.EventListener in project gwt-test-utils by gwt-test-utils.

the class Browser method dispatchEvent.

public static void dispatchEvent(Element element, Event event) {
    canApplyEvent(element, event);
    prepareEvents(element, event);
    // set the related target
    Element relatedTargetElement = JavaScriptObjects.getObject(event, JsoProperties.EVENT_RELATEDTARGET);
    if (relatedTargetElement == null) {
        switch(event.getTypeInt()) {
            case Event.ONMOUSEOVER:
            case Event.ONMOUSEOUT:
                relatedTargetElement = element.getParentElement();
                JavaScriptObjects.setProperty(event, JsoProperties.EVENT_RELATEDTARGET, relatedTargetElement);
                break;
        }
    }
    // For preview event handling
    GwtReflectionUtils.callStaticMethod(DOM.class, "previewEvent", event);
    Element currentElement = element;
    EventListener currentEventListener = DOM.getEventListener((com.google.gwt.user.client.Element) element);
    Set<EventListener> applied = new HashSet<EventListener>();
    while (currentElement != null && !isEventStopped(event)) {
        // for app event handling
        if (currentEventListener != null && !applied.contains(currentEventListener)) {
            applied.add(currentEventListener);
            GwtReflectionUtils.callStaticMethod(DOM.class, "dispatchEvent", event, currentElement, currentEventListener);
        }
        currentElement = currentElement.getParentElement();
        if (currentElement != null) {
            currentEventListener = DOM.getEventListener((com.google.gwt.user.client.Element) currentElement);
        } else {
            currentEventListener = null;
        }
    }
}
Also used : Element(com.google.gwt.dom.client.Element) com.google.gwt.event.dom.client(com.google.gwt.event.dom.client) EventListener(com.google.gwt.user.client.EventListener) HashSet(java.util.HashSet)

Aggregations

EventListener (com.google.gwt.user.client.EventListener)21 Event (com.google.gwt.user.client.Event)15 Element (com.google.gwt.dom.client.Element)7 ClickEvent (com.google.gwt.event.dom.client.ClickEvent)7 SpanElement (com.google.gwt.dom.client.SpanElement)5 KeyDownEvent (com.google.gwt.event.dom.client.KeyDownEvent)5 KeyboardEvent (elemental.events.KeyboardEvent)5 BlurEvent (com.google.gwt.event.dom.client.BlurEvent)4 KeyUpEvent (com.google.gwt.event.dom.client.KeyUpEvent)4 AnchorElement (com.google.gwt.dom.client.AnchorElement)2 ImageElement (com.google.gwt.dom.client.ImageElement)2 Widget (com.google.gwt.user.client.ui.Widget)2 Icon (org.eclipse.che.ide.api.icon.Icon)2 ImageResource2x (org.rstudio.core.client.resources.ImageResource2x)2 SVGImage (org.vectomatic.dom.svg.ui.SVGImage)2 ScheduledCommand (com.google.gwt.core.client.Scheduler.ScheduledCommand)1 EventTarget (com.google.gwt.dom.client.EventTarget)1 Style (com.google.gwt.dom.client.Style)1 com.google.gwt.event.dom.client (com.google.gwt.event.dom.client)1 HandlerRegistration (com.google.gwt.event.shared.HandlerRegistration)1