Search in sources :

Example 26 with NativeEvent

use of com.google.gwt.dom.client.NativeEvent in project rstudio by rstudio.

the class InlineToolbarButton method addClickHandler.

@Override
public HandlerRegistration addClickHandler(ClickHandler clickHandler) {
    /*
       * When we directly subscribe to this widget's ClickEvent, sometimes the
       * click gets ignored (inconsistent repro but it happens enough to be
       * annoying). Doing it this way fixes it.
       */
    hasHandlers_.addHandler(ClickEvent.getType(), clickHandler);
    final HandlerRegistration mouseDown = addDomHandler(new MouseDownHandler() {

        public void onMouseDown(MouseDownEvent event) {
            event.preventDefault();
            event.stopPropagation();
            down_ = true;
        }
    }, MouseDownEvent.getType());
    final HandlerRegistration mouseOut = addDomHandler(new MouseOutHandler() {

        public void onMouseOut(MouseOutEvent event) {
            event.preventDefault();
            event.stopPropagation();
            down_ = false;
        }
    }, MouseOutEvent.getType());
    final HandlerRegistration mouseUp = addDomHandler(new MouseUpHandler() {

        public void onMouseUp(MouseUpEvent event) {
            event.preventDefault();
            event.stopPropagation();
            if (down_) {
                down_ = false;
                NativeEvent clickEvent = Document.get().createClickEvent(1, event.getScreenX(), event.getScreenY(), event.getClientX(), event.getClientY(), event.getNativeEvent().getCtrlKey(), event.getNativeEvent().getAltKey(), event.getNativeEvent().getShiftKey(), event.getNativeEvent().getMetaKey());
                DomEvent.fireNativeEvent(clickEvent, hasHandlers_);
            }
        }
    }, MouseUpEvent.getType());
    return new HandlerRegistration() {

        public void removeHandler() {
            mouseDown.removeHandler();
            mouseOut.removeHandler();
            mouseUp.removeHandler();
        }
    };
}
Also used : HandlerRegistration(com.google.gwt.event.shared.HandlerRegistration) NativeEvent(com.google.gwt.dom.client.NativeEvent)

Example 27 with NativeEvent

use of com.google.gwt.dom.client.NativeEvent in project rstudio by rstudio.

the class AceEditorBackgroundLinkHighlighter method onMouseUp.

@Override
public void onMouseUp(MouseUpEvent mouseUpEvent) {
    // clicks handled in 'onAceClick' for OS X web mode
    if (BrowseCap.isMacintosh() && !BrowseCap.isMacintoshDesktop())
        return;
    NativeEvent event = mouseUpEvent.getNativeEvent();
    if (!isRequiredClickModifier(event))
        return;
    MarkerRegistration marker = getTargetedMarker(event);
    if (marker == null)
        return;
    boolean hasMouseMoved = Math.abs(event.getClientX() - mouseTracker_.getLastMouseX()) >= 2 || Math.abs(event.getClientY() - mouseTracker_.getLastMouseY()) >= 2;
    if (hasMouseMoved)
        return;
    event.stopPropagation();
    event.preventDefault();
    endDetectClickTarget();
    String url = editor_.getTextForRange(marker.getRange());
    navigateToUrl(url);
}
Also used : NativeEvent(com.google.gwt.dom.client.NativeEvent)

Example 28 with NativeEvent

use of com.google.gwt.dom.client.NativeEvent in project rstudio by rstudio.

the class ChunkOptionsPopupPanel method makeInputBox.

private TextBox makeInputBox(final String option, final boolean enquote) {
    final TextBox box = new TextBox();
    box.getElement().setAttribute("placeholder", "Default");
    box.setWidth("40px");
    DomUtils.addKeyHandlers(box, new NativeEventHandler() {

        @Override
        public void onNativeEvent(NativeEvent event) {
            Scheduler.get().scheduleDeferred(new ScheduledCommand() {

                @Override
                public void execute() {
                    String text = box.getText().trim();
                    boolean isEmpty = StringUtil.isNullOrEmpty(text);
                    if (enquote && !isEmpty) {
                        text = StringUtil.ensureQuoted(text);
                        text = text.replaceAll("\\\\", "\\\\\\\\");
                    }
                    if (isEmpty)
                        unset(option);
                    else
                        set(option, text);
                    synchronize();
                }
            });
        }
    });
    return box;
}
Also used : ScheduledCommand(com.google.gwt.core.client.Scheduler.ScheduledCommand) NativeEventHandler(org.rstudio.core.client.dom.DomUtils.NativeEventHandler) TextBox(com.google.gwt.user.client.ui.TextBox) NativeEvent(com.google.gwt.dom.client.NativeEvent)

Example 29 with NativeEvent

use of com.google.gwt.dom.client.NativeEvent in project rstudio by rstudio.

the class StatusBarElementWidget method click.

public void click() {
    NativeEvent evt = Document.get().createMouseDownEvent(0, 0, 0, 0, 0, false, false, false, false, 0);
    ClickEvent.fireNativeEvent(evt, this);
}
Also used : NativeEvent(com.google.gwt.dom.client.NativeEvent)

Example 30 with NativeEvent

use of com.google.gwt.dom.client.NativeEvent in project playn by threerings.

the class HtmlTouch method toEvents.

private Event.Impl[] toEvents(NativeEvent nativeEvent, Events.Flags flags) {
    // Convert the JsArray<Native Touch> to an array of Touch.Events
    JsArray<com.google.gwt.dom.client.Touch> nativeTouches = nativeEvent.getChangedTouches();
    int nativeTouchesLen = nativeTouches.length();
    Event.Impl[] touches = new Event.Impl[nativeTouchesLen];
    for (int t = 0; t < nativeTouchesLen; t++) {
        com.google.gwt.dom.client.Touch touch = nativeTouches.get(t);
        float x = touch.getRelativeX(rootElement);
        float y = touch.getRelativeY(rootElement);
        Point xy = platform.graphics().transformMouse(x, y);
        int id = getTouchIdentifier(nativeEvent, t);
        touches[t] = new Event.Impl(flags, PlayN.currentTime(), xy.x, xy.y, id);
    }
    return touches;
}
Also used : TouchImpl(playn.core.TouchImpl) Point(pythagoras.f.Point) Point(pythagoras.f.Point) NativeEvent(com.google.gwt.dom.client.NativeEvent)

Aggregations

NativeEvent (com.google.gwt.dom.client.NativeEvent)35 Element (com.google.gwt.dom.client.Element)7 JavaScriptObject (com.google.gwt.core.client.JavaScriptObject)3 JsArrayString (com.google.gwt.core.client.JsArrayString)3 TableRowElement (com.google.gwt.dom.client.TableRowElement)3 Column (com.google.gwt.user.cellview.client.Column)3 D3 (org.opennms.features.topology.app.internal.gwt.client.d3.D3)3 MarqueeSelectHandler (org.opennms.features.topology.app.internal.gwt.client.handler.MarqueeSelectHandler)3 PanHandler (org.opennms.features.topology.app.internal.gwt.client.handler.PanHandler)3 SVGGElement (org.opennms.features.topology.app.internal.gwt.client.svg.SVGGElement)3 Context (com.google.gwt.cell.client.Cell.Context)2 ValueUpdater (com.google.gwt.cell.client.ValueUpdater)2 JsArray (com.google.gwt.core.client.JsArray)2 ScheduledCommand (com.google.gwt.core.client.Scheduler.ScheduledCommand)2 EventTarget (com.google.gwt.dom.client.EventTarget)2 ImageElement (com.google.gwt.dom.client.ImageElement)2 HasHandlers (com.google.gwt.event.shared.HasHandlers)2 ImageResource (com.google.gwt.resources.client.ImageResource)2 ListHandler (com.google.gwt.user.cellview.client.ColumnSortEvent.ListHandler)2 HTML (com.google.gwt.user.client.ui.HTML)2