@Override protected void onPreviewNativeEvent(NativePreviewEvent event) { // Check all events outside the combobox to see if they scroll the // page. We cannot use e.g. Window.addScrollListener() because the // scrolled element can be at any level on the page. // Normally this is only called when the popup is showing, but make // sure we don't accidentally process all events when not showing. if (!this.scrollPending && isShowing() && !DOM.isOrHasChild(SuggestionPopup.this.getElement(), Element.as(event.getNativeEvent() .getEventTarget()))) { if (getDesiredLeftPosition() != this.leftPosition || getDesiredTopPosition() != this.topPosition) { updatePopupPositionOnScroll(); } } super.onPreviewNativeEvent(event); }
@Override protected void onPreviewNativeEvent(NativePreviewEvent event) { if (this.resizable) { // We need to preventDefault() on mouseDown events (outside of the // DialogBox content) to keep text from being selected when it // is dragged. NativeEvent nativeEvent = event.getNativeEvent(); if (!event.isCanceled() && (event.getTypeInt() == Event.ONMOUSEDOWN) && calcDragMode(nativeEvent.getClientX(),nativeEvent.getClientY()) >= 0) { nativeEvent.preventDefault(); } } super.onPreviewNativeEvent(event); }
@Override protected void onPreviewNativeEvent(NativePreviewEvent preview) { super.onPreviewNativeEvent(preview); NativeEvent evt = preview.getNativeEvent(); if (evt.getCtrlKey()) { switch (evt.getKeyCode()) { case 'a': case 'A': evt.preventDefault(); okButton.click(); case 'z': case 'Z': evt.preventDefault(); closeButton.click(); break; } } }
@Override protected void onPreviewNativeEvent(NativePreviewEvent preview) { super.onPreviewNativeEvent(preview); NativeEvent evt = preview.getNativeEvent(); if (evt.getType().equals("keydown")) { // Use the popup's key preview hooks to close the dialog when either // enter or escape is pressed. switch (evt.getKeyCode()) { case KeyCodes.KEY_ENTER: case KeyCodes.KEY_ESCAPE: hide(); break; default: break; } } }
@Override protected void onPreviewNativeEvent(NativePreviewEvent preview) { super.onPreviewNativeEvent(preview); NativeEvent evt = preview.getNativeEvent(); if (evt.getCtrlKey()) { switch (evt.getKeyCode()) { case 'a': case 'A': evt.preventDefault(); okButton.click(); case 'z': case 'Z': evt.preventDefault(); closeButton.click(); break; default: break; } } }
@Override public void onPreviewNativeEvent(NativePreviewEvent event) { if (autoCollapseSlider && event != null && !event.isCanceled() && expand) { Event nativeEvent = Event.as(event.getNativeEvent()); switch (nativeEvent.getTypeInt()) { case Event.ONMOUSEDOWN: case Event.ONTOUCHSTART: case Event.ONDBLCLICK: if (eventTargetsPopup(nativeEvent)) { return; } if (eventTargetsInnerElementsPopover(nativeEvent)) { return; } setExpand(false, true); } } }
@Override public void onPreviewNativeEvent(NativePreviewEvent p_event) { if( p_event == null || p_event.getNativeEvent() == null || p_event.getNativeEvent().getEventTarget() == null ) { return; } com.google.gwt.dom.client.Element elmt = com.google.gwt.dom.client.Element.as( p_event .getNativeEvent().getEventTarget() ); if( elmt instanceof InputElement ) { String type = ((InputElement)elmt).getType(); if( type != null && (type.equals( "text" ) || type.equals( "password" ) || type.equals( "textarea" )) ) { return; } } // don't preview event if user is editing someting in an input form m_previewListenerCollection.fireEventPreview( p_event ); }
@Override public void onPreviewNativeEvent(NativePreviewEvent p_event) { if( p_event.getTypeInt() == Event.ONKEYDOWN ) { // start scrolling ? onKeyDown( p_event.getNativeEvent().getKeyCode() ); return; } if( p_event.getTypeInt() == Event.ONKEYUP ) { // stop scrolling ? onKeyUp( p_event.getNativeEvent().getKeyCode() ); return; } if( (p_event.getTypeInt() == Event.ONMOUSEUP) && (m_cancelMouseUpEvent) ) { // cancel event return; } }
@Override public void onPreviewNativeEvent(final NativePreviewEvent event) { final NativeEvent nativeEvent = getEventAndPreventPropagation(event); final String eventType = nativeEvent.getType(); if ("mousemove".equals(eventType)) { moveColumn(nativeEvent.getClientX()); } else if ("mouseup".equals(eventType)) { handler.removeHandler(); ghostColumn.removeFromParent(); ghostLine.removeFromParent(); if (fromIndex != toIndex) { columnMoved(fromIndex, toIndex); } dragCallback.dragFinished(); } }
@PostConstruct private void setup() { globalHandlerRegistration = com.google.gwt.user.client.Event.addNativePreviewHandler(new NativePreviewHandler() { @Override public void onPreviewNativeEvent(NativePreviewEvent event) { if (event.getTypeInt() == com.google.gwt.user.client.Event.ONKEYPRESS && event.getNativeEvent().getCharCode() == 'm' && event.getNativeEvent().getCtrlKey()) { if (maximizedPanel != null) { maximizedPanel.unmaximize(); maximizedPanel = null; } else if (activePart != null) { WorkbenchPanelPresenter activePanelPresenter = mapPanelDefinitionToPresenter.get(activePart.getParentPanel()); activePanelPresenter.maximize(); maximizedPanel = activePanelPresenter; } } } }); }
@Override protected void onPreviewNativeEvent(NativePreviewEvent preview) { super.onPreviewNativeEvent(preview); NativeEvent evt = preview.getNativeEvent(); if (evt.getType() .equals("keydown")) { // Use the popup's key preview hooks to close the dialog when either // enter or escape is pressed. switch (evt.getKeyCode()) { case KeyCodes.KEY_ENTER: case KeyCodes.KEY_ESCAPE: hide(); break; } } }
public ResizePanel(AvroUiStyle style) { super(); DOM.sinkEvents(this.getElement(), Event.ONMOUSEDOWN | Event.ONMOUSEMOVE | Event.ONMOUSEUP | Event.ONMOUSEOVER); addStyleName(style.resizePanel()); resizeElement = DOM.createDiv(); resizeElement.addClassName(style.resizeHandle()); this.getElement().appendChild(resizeElement); Event.addNativePreviewHandler(new NativePreviewHandler() { public void onPreviewNativeEvent(NativePreviewEvent event) { if (resize) { int clientX = event.getNativeEvent().getClientX(); int clientY = event.getNativeEvent().getClientY(); int originalX = getElement().getAbsoluteLeft(); int originalY = getElement().getAbsoluteTop(); if (clientX < originalX || clientY < originalY) { event.cancel(); } } } }); }
@Override protected void onPreviewNativeEvent(NativePreviewEvent preview) { super.onPreviewNativeEvent(preview); NativeEvent evt = preview.getNativeEvent(); if (evt.getType().equals("keydown")) { // Use the popup's key preview hooks to close the dialog when either // enter or escape is pressed. switch (evt.getKeyCode()) { case KeyCodes.KEY_ENTER: case KeyCodes.KEY_ESCAPE: hide(); break; } } }
private void startRectangle() { cleanup(); container = mapPresenter.getContainerManager().addScreenContainer(); zoomToRectangleGroup = new ZoomToRectGroup(mapPresenter.getViewPort()); escapeHandler = Event.addNativePreviewHandler(new NativePreviewHandler() { public void onPreviewNativeEvent(NativePreviewEvent event) { if (event.getTypeInt() == Event.ONKEYDOWN || event.getTypeInt() == Event.ONKEYPRESS) { if (KeyCodes.KEY_ESCAPE == event.getNativeEvent().getKeyCode()) { cleanup(); } } } }); container.add(zoomToRectangleGroup); }
@Override protected void onPreviewNativeEvent(NativePreviewEvent event) { if (event.getNativeEvent().getType().equals("keydown") && event.isFirstHandler()) { switch (event.getNativeEvent().getKeyCode()) { case KeyCodes.KEY_ESCAPE: if (!(getFocusedWidget() instanceof PreventsKeyboardClose)) { event.consume(); closeCancel(); } break; case KeyCodes.KEY_ENTER: // typeahead box hides this panel automatically if possible if (!(getFocusedWidget() instanceof PreventsKeyboardClose)) { event.consume(); closeOk(); } break; } } }
@Override public void onPreviewNativeEvent(NativePreviewEvent event) { final NativeEvent natEvent = event.getNativeEvent(); final Element element = natEvent.getEventTarget().cast(); final String eventType = natEvent.getType(); if (!(element == left || element == right)) { if ("mousedown".equals(eventType)) { //No need to do anything, the event will be passed on to the column sort handler } else if (!dragging && "mouseover".equals(eventType)) { cleanUp(); } return; } final NativeEvent nativeEvent = getEventAndPreventPropagation(event); if ("mousedown".equals(eventType)) { if (element == right) { left.removeFromParent(); new ColumnResizeHelper(this, source, right, nativeEvent); } else new ColumnMoverHelper(this, source, nativeEvent); dragging = true; } }
/** * The constructor should first call super() to initialize the component and * then handle any initialization relevant to Vaadin. */ public CustomOverlayWidget() { setWidget(new HTML()); // Seems that we need this one overlay = new PopupPanel(); overlay.addStyleName(CLASSNAME); overlay.setAutoHideEnabled(false); overlay.setAnimationEnabled(false); overlay.setModal(false); Event.addNativePreviewHandler(new NativePreviewHandler() { public void onPreviewNativeEvent(NativePreviewEvent event) { int typeInt = event.getTypeInt(); // We're only listening for these if (typeInt == Event.ONSCROLL) { CustomOverlayWidget.this.updateOverlayPosition(); } } }); }
@Override public void onPreviewNativeEvent(NativePreviewEvent event) { EventTarget target = event.getNativeEvent().getEventTarget(); Element targetElement = null; if (Element.is(target)) { targetElement = Element.as(target); } if (getWidget().getModalityCurtain().isOrHasChild(targetElement) && getWidget().isClosable() && (event.getTypeInt() & ACCEPTEDEVENTS) == 0) { /* * Close on events outside window. Special handling for mousemove * etc to aid compatibility with desktop (testing purposes). */ rpc.close(); } }
@Override protected void onPreviewNativeEvent(NativePreviewEvent event) { super.onPreviewNativeEvent(event); if (isEscapeToHide() && event.getNativeEvent().getKeyCode() == KeyCodes.KEY_ESCAPE) { AriaStatus.getInstance().setText(ARIA.dialogClosed(getText())); hide(); } if (isEnterToSubmit() && event.getNativeEvent().getKeyCode() == KeyCodes.KEY_ENTER) { event.getNativeEvent().stopPropagation(); event.getNativeEvent().preventDefault(); iSubmitHandler.execute(); } }
/** * ExtendedPopupPanel */ public ExtendedPopupPanel(boolean autoHide, boolean modal) { super(autoHide, modal); // Ensures when mouseup / onclick / ondblclick event is disabled drag flag and not consumed by popup Event.addNativePreviewHandler(new NativePreviewHandler() { @Override public void onPreviewNativeEvent(NativePreviewEvent event) { int type = event.getTypeInt(); if (type == Event.ONMOUSEUP || type == Event.ONCLICK || type == Event.ONDBLCLICK) { Main.get().activeFolderTree.disableDragged(); } } }); }
@Override protected void onPreviewNativeEvent(NativePreviewEvent preview) { super.onPreviewNativeEvent(preview); // Use the popup's key preview hooks to close the dialog when either // enter or escape is pressed. NativeEvent evt = preview.getNativeEvent(); if (evt.getType().equals(KEYDOWN) && evt.getKeyCode() == KeyCodes.KEY_ESCAPE && performCancelOnEscape && listener != null && cancelButton.isVisible()) { listener.onCancelClick(); hide(); } }
@Override protected void onPreviewNativeEvent(NativePreviewEvent preview) { super.onPreviewNativeEvent(preview); NativeEvent evt = preview.getNativeEvent(); if (evt.getType().equals("keydown") && evt.getKeyCode() == KeyCodes.KEY_ESCAPE) { // Use the popup's key preview hooks to close the dialog when either // enter or escape is pressed. hide(); } }
@Override protected void onPreviewNativeEvent(NativePreviewEvent preview) { super.onPreviewNativeEvent(preview); NativeEvent evt = preview.getNativeEvent(); if (evt.getType().equals("keydown") && evt.getKeyCode() == KeyCodes.KEY_ESCAPE) { hide(); } }
/** * Processes a native event so that we can track mouse movements in and * out of this widget. * @param event */ protected void onPreviewNativeEvent(NativePreviewEvent event) { if (event.getTypeInt() == Event.ONMOUSEMOVE) { int x = event.getNativeEvent().getClientX(); int y = event.getNativeEvent().getClientY(); handleMouseMove(x, y); } }
@Override // Exception squid:S1604 - GWT 2.7 does not support Java 8 @SuppressWarnings("squid:S1604") public void accept(final VDragEvent drag, final UIDL configuration, final VAcceptCallback callback) { if (isDragStarting(drag)) { final NativePreviewHandler nativeEventHandler = new NativePreviewHandler() { @Override public void onPreviewNativeEvent(NativePreviewEvent event) { if (isEscKey(event) || isMouseUp(event)) { try { hideDropTargetHints(configuration); } finally { nativeEventHandlerRegistration.removeHandler(); } } } }; nativeEventHandlerRegistration = Event.addNativePreviewHandler(nativeEventHandler); setMultiRowDragDecoration(drag); } int childCount = configuration.getChildCount(); accepted = false; for (int childIndex = 0; childIndex < childCount; childIndex++) { VAcceptCriterion crit = getCriteria(configuration, childIndex); crit.accept(drag, configuration.getChildUIDL(childIndex), this); if (Boolean.TRUE.equals(accepted)) { callback.accepted(drag); return; } } // if no VAcceptCriterion accepts and the mouse is release, an error // message is shown if (Event.ONMOUSEUP == Event.getTypeInt(drag.getCurrentGwtEvent().getType())) { showErrorNotification(drag); } }
/** * Checks if the origin of the given event is a pressed ESC key. * * @param event * the event to analyze * @return <code>true</code> if the origin of the event is a pressed ESC * key, otherwise <code>false</code>. */ private static boolean isEscKey(final NativePreviewEvent event) { int typeInt = event.getTypeInt(); if (typeInt == Event.ONKEYDOWN) { int keyCode = event.getNativeEvent().getKeyCode(); if (KeyCodes.KEY_ESCAPE == keyCode) { return true; } } return false; }
@Override protected void init() { super.init(); dummyRootMenuBar = GWT.create(MyVMenuBar.class); CustomMenuItem item = GWT.create(CustomMenuItem.class); dummyRootMenuBar.getItems().add(item); contextMenuWidget = new MyVMenuBar(true, dummyRootMenuBar); item.setSubMenu(contextMenuWidget); // application connection that is used for all our overlays MyVOverlay.setApplicationConnection(this.getConnection()); registerRpc(ContextMenuClientRpc.class, new ContextMenuClientRpc() { @Override public void showContextMenu(int x, int y) { showMenu(x, y); } }); Event.addNativePreviewHandler(new NativePreviewHandler() { @Override public void onPreviewNativeEvent(NativePreviewEvent event) { if (event.getTypeInt() == Event.ONKEYDOWN && contextMenuWidget.isPopupShowing()) { boolean handled = contextMenuWidget.handleNavigation( event.getNativeEvent().getKeyCode(), event.getNativeEvent().getCtrlKey(), event.getNativeEvent().getShiftKey()); if (handled) { event.cancel(); } } } }); }
/** * pressing ESC closes the dialogbox */ @Override protected void onPreviewNativeEvent(NativePreviewEvent event) { super.onPreviewNativeEvent(event); if (event.getTypeInt() == Event.ONKEYDOWN && event.getNativeEvent().getKeyCode() == KeyCodes.KEY_ESCAPE) { hide(); } }
@Override public void onPreviewNativeEvent(NativePreviewEvent p_event) { if( (p_event.getTypeInt() == Event.ONKEYPRESS) && (p_event.getNativeEvent().getCtrlKey()) ) { if( p_event.getNativeEvent().getKeyCode() == 'm' || p_event.getNativeEvent().getKeyCode() == 'M' ) { // cancel event return; } } }
@Override public void onPreviewNativeEvent(final NativePreviewEvent event) { final NativeEvent natEvent = event.getNativeEvent(); final Element element = natEvent.getEventTarget().cast(); final String eventType = natEvent.getType(); if (!(element == moveHandle || element == resizeHandle)) { if ("mousedown".equals(eventType)) { //No need to do anything, the event will be passed on to the column sort handler } else if (!dragging && "mouseover".equals(eventType)) { cleanUp(); } return; } final NativeEvent nativeEvent = getEventAndPreventPropagation(event); if ("mousedown".equals(eventType)) { if (element == resizeHandle) { moveHandle.removeFromParent(); new ColumnResizeHelper(this, source, nativeEvent); } else { new ColumnMoverHelper(this, source, nativeEvent); } dragging = true; } }
@Override public void onPreviewNativeEvent(final NativePreviewEvent event) { final NativeEvent nativeEvent = getEventAndPreventPropagation(event); final int clientX = nativeEvent.getClientX(); final String eventType = nativeEvent.getType(); if ("mousemove".equals(eventType)) { moveLine(clientX); } else if ("mouseup".equals(eventType)) { handler.removeHandler(); resizeLine.removeFromParent(); dragCallback.dragFinished(); columnResized(Math.max(clientX - header.getAbsoluteLeft(), MINIMUM_COLUMN_WIDTH)); } }