javafx.event.EventDispatchChain Java Examples
The following examples show how to use
javafx.event.EventDispatchChain.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: FXCanvasEx.java From gef with Eclipse Public License 2.0 | 5 votes |
@Override public Event dispatchEvent(final Event event, final EventDispatchChain tail) { if (JAVA_8) { // XXX: Ensure key events that result from to be ignored SWT key // events (doit == false) are forwarded as consumed // (https://bugs.openjdk.java.net/browse/JDK-8159227) // TODO: Remove when dropping support for JavaSE-1.8. if (event instanceof javafx.scene.input.KeyEvent) { org.eclipse.swt.widgets.Event lastDownEvent = unprocessedKeyDownEvents .peek(); if (event.getEventType() .equals(javafx.scene.input.KeyEvent.KEY_PRESSED)) { if (!lastDownEvent.doit) { event.consume(); } // remove key down event and save it so that its doit // flag can be checked in case a KEY_TYPED event is // generated for it downEvent = unprocessedKeyDownEvents.poll(); // System.out.println("pressed " // + ((javafx.scene.input.KeyEvent) event) // .getCode() // + " :: " + "down=" // + unprocessedKeyDownEvents.size() + ", up=" // + unprocessedKeyUpEvents.size()); } else if (event.getEventType() .equals(javafx.scene.input.KeyEvent.KEY_TYPED)) { // consume event if last key down event was consumed if (!downEvent.doit) { event.consume(); } // System.out.println("typed " // + ((javafx.scene.input.KeyEvent) event) // .getCharacter() // + " :: " + "down=" // + unprocessedKeyDownEvents.size() + ", up=" // + unprocessedKeyUpEvents.size()); } else if (event.getEventType() .equals(javafx.scene.input.KeyEvent.KEY_RELEASED)) { // remove key up event org.eclipse.swt.widgets.Event lastUpEvent = unprocessedKeyUpEvents .poll(); if (!lastUpEvent.doit) { event.consume(); } // System.out.println("released " // + ((javafx.scene.input.KeyEvent) event) // .getCode() // + " :: " + "down=" // + unprocessedKeyDownEvents.size() + ", up=" // + unprocessedKeyUpEvents.size()); } } } // dispatch the most recent event Event returnedEvent = delegate.dispatchEvent(event, tail); // update UI (added to fix // https://bugs.openjdk.java.net/browse/JDK-8161587) long millisNow = System.currentTimeMillis(); if (millisNow - lastRedrawMillis > REDRAW_INTERVAL_MILLIS) { redraw(); if (WIN32) { // XXX: Only call update() on some platforms to prevent a // loss of performance while keeping the UI up-to-date. update(); } lastRedrawMillis = millisNow; } // return dispatched event return returnedEvent; }
Example #2
Source File: WebEventDispatcher.java From mars-sim with GNU General Public License v3.0 | 5 votes |
@Override public Event dispatchEvent(Event event, EventDispatchChain tail) { if (event instanceof MouseEvent){ MouseEvent m = (MouseEvent)event; if (event.getEventType().equals(MouseEvent.MOUSE_CLICKED) || event.getEventType().equals(MouseEvent.MOUSE_PRESSED)) { Point2D origin = new Point2D(m.getX(),m.getY()); if (limit != null) allowDrag = !(origin.getX() < limit.getX() && origin.getY() < limit.getY()); } // avoid selection with mouse dragging, allowing dragging the scrollbars if (event.getEventType().equals(MouseEvent.MOUSE_DRAGGED)) { if(!allowDrag){ event.consume(); } } // Avoid selection of word, line, paragraph with mouse click if(m.getClickCount() > 1){ event.consume(); } } if (event instanceof KeyEvent && event.getEventType().equals(KeyEvent.KEY_PRESSED)){ KeyEvent k = (KeyEvent)event; // Avoid copy with Ctrl+C or Ctrl+Insert if((k.getCode().equals(KeyCode.C) || k.getCode().equals(KeyCode.INSERT)) && k.isControlDown()){ event.consume(); } // Avoid selection with shift+Arrow if(k.isShiftDown() && (k.getCode().equals(KeyCode.RIGHT) || k.getCode().equals(KeyCode.LEFT) || k.getCode().equals(KeyCode.UP) || k.getCode().equals(KeyCode.DOWN))){ event.consume(); } } return oldDispatcher.dispatchEvent(event, tail); }
Example #3
Source File: GoogleMapView.java From GMapsFX with Apache License 2.0 | 5 votes |
@Override public Event dispatchEvent(Event event, EventDispatchChain tail) { if (event instanceof MouseEvent) { MouseEvent mouseEvent = (MouseEvent) event; if (mouseEvent.getClickCount() > 1) { if (disableDoubleClick) { mouseEvent.consume(); } } } return originalDispatcher.dispatchEvent(event, tail); }
Example #4
Source File: ListPopup.java From oim-fx with MIT License | 4 votes |
@Override public EventDispatchChain buildEventDispatchChain(EventDispatchChain tail) { return super.buildEventDispatchChain(tail).append(eventHandlerManager); }
Example #5
Source File: JFXAlert.java From JFoenix with Apache License 2.0 | 4 votes |
/** * {@inheritDoc} */ @Override public EventDispatchChain buildEventDispatchChain(EventDispatchChain tail) { return super.buildEventDispatchChain(tail).prepend(eventHandlerManager); }
Example #6
Source File: JFXTooltip.java From JFoenix with Apache License 2.0 | 4 votes |
/** * {@inheritDoc} */ @Override public EventDispatchChain buildEventDispatchChain(EventDispatchChain tail) { return super.buildEventDispatchChain(tail).prepend(eventHandlerManager); }