Java Code Examples for javafx.scene.input.KeyEvent#getSource()
The following examples show how to use
javafx.scene.input.KeyEvent#getSource() .
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: MultiplierView.java From trex-stateless-gui with Apache License 2.0 | 7 votes |
/** * Validate input event handler * * @return */ @Override public EventHandler<KeyEvent> validateInput() { return (KeyEvent event) -> { TextField source = (TextField) event.getSource(); if (".".equals(event.getCharacter()) && source.getText().contains(".")) { event.consume(); } if ((event.getCode() == KeyCode.BACK_SPACE && Util.isNullOrEmpty(source.getText())) || ".".equals(source.getText())) { return; } updateAll(currentSelected); optionValueChangeHandler.optionValueChanged(); }; }
Example 2
Source File: AutocompleteMenu.java From phoebus with Eclipse Public License 1.0 | 6 votes |
/** Toggle menu on Ctrl-Space * * <p>Called by both the text field and the context menu */ private void toggleMenu(final KeyEvent event) { // For Mac, isShortcutDown() to detect Command-SPACE // seemed natural, but that is already captured by OS // for 'Spotlight Search', // so use Ctrl-Space on all OS if (event.isControlDown() && event.getCode() == KeyCode.SPACE) { if (menu.isShowing()) menu.hide(); else if (event.getSource() instanceof TextField) { final TextInputControl field = (TextInputControl) event.getSource(); // Show menu with current content, // in case we were hiding and are now showing the menu // for the same field, not loosing focus, // menu already populated showMenuForField(field); // Certainly need to perform lookup if menu is empty. // Otherwise, cannot hurt to 'refresh' lookup(field); } event.consume(); } }
Example 3
Source File: PacketHex.java From trex-stateless-gui with Apache License 2.0 | 6 votes |
/** * * @param maxLengh * @return */ public EventHandler<KeyEvent> hex_Validation(final Integer maxLengh) { return new EventHandler<KeyEvent>() { @Override public void handle(KeyEvent e) { TextField hexLine = (TextField) e.getSource(); if (hexLine.getSelection() != null) { hexLine.deleteText(hexLine.getSelection()); } if (hexLine.getText().length() >= maxLengh) { e.consume(); } if (!e.getCharacter().matches("[0-9A-Fa-f]")) { e.consume(); } } }; }
Example 4
Source File: TableUtils.java From kafka-message-tool with MIT License | 5 votes |
public void handle(final KeyEvent keyEvent) { if (copyKeyCodeCombination.match(keyEvent)) { if (keyEvent.getSource() instanceof TableView) { copySelectionToClipboard((TableView<?>) keyEvent.getSource()); keyEvent.consume(); } } }
Example 5
Source File: TableUtils.java From old-mzmine3 with GNU General Public License v2.0 | 5 votes |
public void handle(final KeyEvent keyEvent) { if (keyCodeCompination.match(keyEvent)) { if (keyEvent.getSource() instanceof TreeTableView) { // Copy to clipboard copySelectionToClipboard((TreeTableView<?>) keyEvent.getSource()); // Event is handled, consume it keyEvent.consume(); } } }
Example 6
Source File: Tools.java From logbook-kai with MIT License | 5 votes |
/** * キーボードイベントのハンドラー(Ctrl+Cを実装) * * @param event キーボードイベント */ public static void defaultOnKeyPressedHandler(KeyEvent event) { if (event.getSource() instanceof TableView<?>) { TableView<?> table = (TableView<?>) event.getSource(); // Copy if (event.isControlDown() && event.getCode() == KeyCode.C) { selectionCopy(table); } } }