Java Code Examples for javafx.event.Event#consume()
The following examples show how to use
javafx.event.Event#consume() .
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: ControlPanelPlaylistsController.java From MusicPlayer with MIT License | 6 votes |
@FXML private void deleteSong(Event e) { // Gets the play lists controller sub view, which keeps track of the currently selected song. // A PlayListsController object will always be returned since this button will only be visible // when the user selects a song while in a play list. PlaylistsController controller = (PlaylistsController) MusicPlayer.getMainController().getSubViewController(); // Retrieves play list and song id to search for the song in the xml file. int selectedPlayListId = controller.getSelectedPlaylist().getId(); int selectedSongId = controller.getSelectedSong().getId(); // Calls methods to delete selected song from play list in XML file. XMLEditor.deleteSongFromPlaylist(selectedPlayListId, selectedSongId); // Removes the selected song from the playlist's song list in Library. Library.getPlaylist(selectedPlayListId).removeSong(selectedSongId); // Deletes the selected row from the table view. controller.deleteSelectedRow(); e.consume(); }
Example 2
Source File: EditorAreaComponent.java From jmonkeybuilder with Apache License 2.0 | 5 votes |
@FxThread private void handleRequestToCloseEditor(@NotNull FileEditor editor, @NotNull Tab tab, @NotNull Event event) { if (!editor.isDirty()) { return; } var question = Messages.EDITOR_AREA_SAVE_FILE_QUESTION .replace("%file_name%", editor.getFileName()); var dialog = new ConfirmDialog(result -> { if (result == null) { return; } if (result) { editor.save(fileEditor -> getTabs().remove(tab)); } else { getTabs().remove(tab); } }, question); dialog.show(); event.consume(); }
Example 3
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 4
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 5
Source File: ControlPanelPlaylistsController.java From MusicPlayer with MIT License | 4 votes |
@FXML private void playSong(Event e) { SubView controller = MusicPlayer.getMainController().getSubViewController(); controller.play(); e.consume(); }
Example 6
Source File: ControlPanelController.java From MusicPlayer with MIT License | 4 votes |
@FXML private void playSong(Event e) { SubView controller = MusicPlayer.getMainController().getSubViewController(); controller.play(); e.consume(); }