Search in sources :

Example 46 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 47 with NativeEvent

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

the class WebGLDemo method createTexture.

private WebGLTexture createTexture(String url) {
    // Create the texture object.
    final WebGLTexture tex = gl.createTexture();
    // Load the image.
    final ImageElement img = createImage();
    img.setSrc(url);
    hookOnLoad(img, new EventHandler() {

        @Override
        public void onEvent(NativeEvent e) {
            // Load image data into the texture object once it's loaded.
            gl.bindTexture(TEXTURE_2D, tex);
            gl.texImage2D(TEXTURE_2D, 0, RGBA, RGBA, UNSIGNED_BYTE, img);
            gl.texParameteri(TEXTURE_2D, TEXTURE_MAG_FILTER, LINEAR);
            gl.texParameteri(TEXTURE_2D, TEXTURE_MIN_FILTER, LINEAR);
            gl.texParameteri(TEXTURE_2D, TEXTURE_WRAP_S, CLAMP_TO_EDGE);
            gl.texParameteri(TEXTURE_2D, TEXTURE_WRAP_T, CLAMP_TO_EDGE);
            gl.bindTexture(TEXTURE_2D, null);
        }
    });
    return tex;
}
Also used : WebGLTexture(com.google.gwt.webgl.client.WebGLTexture) ImageElement(com.google.gwt.dom.client.ImageElement) NativeEvent(com.google.gwt.dom.client.NativeEvent)

Example 48 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)

Example 49 with NativeEvent

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

the class DiffScreen method onGutterClick.

private GutterClickHandler onGutterClick(final CodeMirror cm) {
    return new GutterClickHandler() {

        @Override
        public void handle(CodeMirror instance, final int line, final String gutterClass, NativeEvent clickEvent) {
            if (Element.as(clickEvent.getEventTarget()).hasClassName(getLineNumberClassName()) && clickEvent.getButton() == NativeEvent.BUTTON_LEFT && !clickEvent.getMetaKey() && !clickEvent.getAltKey() && !clickEvent.getCtrlKey() && !clickEvent.getShiftKey()) {
                cm.setCursor(Pos.create(line));
                Scheduler.get().scheduleDeferred(new ScheduledCommand() {

                    @Override
                    public void execute() {
                        getCommentManager().newDraftOnGutterClick(cm, gutterClass, line + 1);
                    }
                });
            }
        }
    };
}
Also used : ScheduledCommand(com.google.gwt.core.client.Scheduler.ScheduledCommand) GutterClickHandler(net.codemirror.lib.CodeMirror.GutterClickHandler) CodeMirror(net.codemirror.lib.CodeMirror) NativeEvent(com.google.gwt.dom.client.NativeEvent)

Example 50 with NativeEvent

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

the class SearchControl method initializeCellAutocompleteWidget.

private void initializeCellAutocompleteWidget() {
    final AbstractSafeHtmlRenderer<NodeMarker> renderer = new AbstractSafeHtmlRenderer<NodeMarker>() {

        @Override
        public SafeHtml render(final NodeMarker marker) {
            final SafeHtmlBuilder builder = new SafeHtmlBuilder();
            final String search = m_inputBox.getValue();
            builder.appendHtmlConstant("<div class=\"autocomplete-label\">");
            builder.appendHtmlConstant(marker.getNodeLabel());
            builder.appendHtmlConstant("</div>");
            String additionalSearchInfo = null;
            if (search != null && (search.contains(":") || search.contains("="))) {
                final String searchKey = search.replaceAll("[\\:\\=].*$", "").toLowerCase();
                LOG.info("searchKey = " + searchKey);
                final Map<String, String> props = marker.getProperties();
                if ("category".equals(searchKey) || "categories".equals(searchKey)) {
                    final String catString = props.get("categories");
                    if (catString != null) {
                        additionalSearchInfo = catString;
                    }
                }
                for (final Map.Entry<String, String> entry : props.entrySet()) {
                    final String key = entry.getKey().toLowerCase();
                    final Object value = entry.getValue();
                    if (key.equals(searchKey) && m_labels.containsKey(key)) {
                        additionalSearchInfo = m_labels.get(key) + ": " + value;
                        break;
                    }
                }
            }
            if (additionalSearchInfo != null) {
                builder.appendHtmlConstant("<div class=\"autocomplete-additional-info\">").appendHtmlConstant(additionalSearchInfo).appendHtmlConstant("</div>");
            }
            return builder.toSafeHtml();
        }
    };
    final AbstractSafeHtmlCell<NodeMarker> cell = new AbstractSafeHtmlCell<NodeMarker>(renderer, "keydown", "click", "dblclick", "touchstart") {

        @Override
        public void onBrowserEvent(final Context context, final com.google.gwt.dom.client.Element parent, final NodeMarker value, final NativeEvent event, final ValueUpdater<NodeMarker> valueUpdater) {
            LOG.info("SearchControl.AutocompleteCell.onBrowserEvent(): context = " + context + ", parent = " + parent + ", value = " + value + ", event = " + event);
            if (m_stateManager.handleAutocompleteEvent(event)) {
                super.onBrowserEvent(context, parent, value, event, valueUpdater);
            }
        }

        @Override
        protected void render(final Context context, final SafeHtml data, final SafeHtmlBuilder builder) {
            builder.appendHtmlConstant("<div class=\"autocomplete-entry\">");
            if (data != null) {
                builder.append(data);
            }
            builder.appendHtmlConstant("</div>");
        }
    };
    m_autoComplete = new CellList<NodeMarker>(cell);
    m_autoComplete.setSelectionModel(m_selectionModel);
    m_autoComplete.setKeyboardSelectionPolicy(KeyboardSelectionPolicy.BOUND_TO_SELECTION);
    m_autoComplete.setVisible(false);
    m_autoComplete.addStyleName("search-autocomplete");
    setIdIfMissing(m_autoComplete, "searchControl.autoComplete");
}
Also used : AbstractSafeHtmlRenderer(com.google.gwt.text.shared.AbstractSafeHtmlRenderer) SafeHtml(com.google.gwt.safehtml.shared.SafeHtml) Element(com.google.gwt.user.client.Element) SafeHtmlBuilder(com.google.gwt.safehtml.shared.SafeHtmlBuilder) JSNodeMarker(org.opennms.features.vaadin.nodemaps.internal.gwt.client.JSNodeMarker) NodeMarker(org.opennms.features.vaadin.nodemaps.internal.gwt.client.NodeMarker) ValueUpdater(com.google.gwt.cell.client.ValueUpdater) AbstractSafeHtmlCell(com.google.gwt.cell.client.AbstractSafeHtmlCell) HashMap(java.util.HashMap) Map(java.util.Map) NativeEvent(com.google.gwt.dom.client.NativeEvent)

Aggregations

NativeEvent (com.google.gwt.dom.client.NativeEvent)72 Element (com.google.gwt.dom.client.Element)20 Test (org.junit.Test)12 Column (com.google.gwt.user.cellview.client.Column)8 ValueUpdater (com.google.gwt.cell.client.ValueUpdater)6 EventTarget (com.google.gwt.dom.client.EventTarget)6 SafeHtmlBuilder (com.google.gwt.safehtml.shared.SafeHtmlBuilder)5 MonacoStandaloneCodeEditor (org.uberfire.client.views.pfly.monaco.jsinterop.MonacoStandaloneCodeEditor)5 AbstractCell (com.google.gwt.cell.client.AbstractCell)4 JavaScriptObject (com.google.gwt.core.client.JavaScriptObject)4 Context (com.google.gwt.cell.client.Cell.Context)3 JsArrayString (com.google.gwt.core.client.JsArrayString)3 Scheduler (com.google.gwt.core.client.Scheduler)3 Style (com.google.gwt.dom.client.Style)3 TableRowElement (com.google.gwt.dom.client.TableRowElement)3 BlurEvent (com.google.gwt.event.dom.client.BlurEvent)3 Widget (com.google.gwt.user.client.ui.Widget)3 HTMLButtonElement (elemental2.dom.HTMLButtonElement)3 Button (org.gwtbootstrap3.client.ui.Button)3 Icon (org.gwtbootstrap3.client.ui.Icon)3