Java Code Examples for javafx.scene.input.KeyCode#BACK_SPACE
The following examples show how to use
javafx.scene.input.KeyCode#BACK_SPACE .
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: CreateNewAccount.java From ChatRoomFX with MIT License | 5 votes |
@FXML private void namingFieldsRestriction(KeyEvent event){ if(!event.getCharacter().matches("[a-z]|[A-Z]+")&&(event.getCode()!= KeyCode.BACK_SPACE)&&!(event.getCharacter().matches("\\s"))){ event.consume(); } }
Example 3
Source File: MainViewController.java From trex-stateless-gui with Apache License 2.0 | 5 votes |
/** * Handle key down event * * @param event */ @Override public void handle(KeyEvent event) { if (!event.getCharacter().matches("[0-9]") && event.getCode() != KeyCode.BACK_SPACE) { event.consume(); } }
Example 4
Source File: ComboBoxKeyHandler.java From metastone with GNU General Public License v2.0 | 5 votes |
@Override public void handle(KeyEvent event) { if (System.currentTimeMillis() - WORD_DELAY > lastKeyPress) { s = ""; } // handle non alphanumeric keys like backspace, delete etc if (event.getCode() == KeyCode.BACK_SPACE && s.length() > 0) s = s.substring(0, s.length() - 1); else s += event.getText(); lastKeyPress = System.currentTimeMillis(); if (s.length() == 0) { select(0); return; } for (T item : box.getItems()) { String name = box.getConverter().toString(item).toLowerCase(); if (name.startsWith(s)) { select(item); return; } } // nothing found, reset search string s = ""; }
Example 5
Source File: TranslationController.java From BetonQuest-Editor with GNU General Public License v3.0 | 5 votes |
@FXML public void translationKey(KeyEvent event) { try { KeyCombination enter = new KeyCodeCombination(KeyCode.ENTER, KeyCombination.CONTROL_DOWN); KeyCombination backspace = new KeyCodeCombination(KeyCode.BACK_SPACE, KeyCombination.CONTROL_DOWN); if (enter.match(event)) { next(); } else if (backspace.match(event)) { previous(); } } catch (Exception e) { ExceptionController.display(e); } }
Example 6
Source File: AutoCompleteComboBoxListener.java From Path-of-Leveling with MIT License | 4 votes |
@Override public void handle(KeyEvent event) { if(event.getCode() == KeyCode.UP) { caretPos = -1; moveCaret(comboBox.getEditor().getText().length()); return; } else if(event.getCode() == KeyCode.DOWN) { if(!comboBox.isShowing()) { comboBox.show(); } caretPos = -1; moveCaret(comboBox.getEditor().getText().length()); return; } else if(event.getCode() == KeyCode.BACK_SPACE) { moveCaretToPos = true; caretPos = comboBox.getEditor().getCaretPosition(); } else if(event.getCode() == KeyCode.DELETE) { moveCaretToPos = true; caretPos = comboBox.getEditor().getCaretPosition(); } if(event.getCharacter().matches("[a-z]")) comboBox.setValue( (T) String.valueOf(comboBox.getValue()).toUpperCase() ); if (event.getCode() == KeyCode.RIGHT || event.getCode() == KeyCode.LEFT || event.isControlDown() || event.getCode() == KeyCode.HOME || event.getCode() == KeyCode.END || event.getCode() == KeyCode.TAB) { return; } //if(comboBox.getItems().isEmpty()) comboBox.getItems().addAll(data); ObservableList<T> list = FXCollections.observableArrayList(); for (T aData : data) { if(sc.toString(aData).toLowerCase().contains (AutoCompleteComboBoxListener.this.comboBox .getEditor().getText().toLowerCase()) ){ list.add(aData); } /* if (String.valueOf(aData).toLowerCase().startsWith( AutoCompleteComboBoxListener.this.comboBox .getEditor().getText().toLowerCase())) { list.add(aData); }*/ } String t = comboBox.getEditor().getText(); comboBox.getItems().clear(); comboBox.getItems().addAll(list); comboBox.getEditor().setText(t); if(!moveCaretToPos) { caretPos = -1; } moveCaret(t.length()); if(!list.isEmpty()) { comboBox.show(); } }
Example 7
Source File: OSFXUtils.java From marathonv5 with Apache License 2.0 | 4 votes |
public static String keyEventGetKeyText(KeyCode keycode) { if (keycode == KeyCode.TAB) { return "Tab"; } if (keycode == KeyCode.CONTROL) { return "Ctrl"; } if (keycode == KeyCode.ALT) { return "Alt"; } if (keycode == KeyCode.SHIFT) { return "Shift"; } if (keycode == KeyCode.META) { return "Meta"; } if (keycode == KeyCode.SPACE) { return "Space"; } if (keycode == KeyCode.BACK_SPACE) { return "Backspace"; } if (keycode == KeyCode.HOME) { return "Home"; } if (keycode == KeyCode.END) { return "End"; } if (keycode == KeyCode.DELETE) { return "Delete"; } if (keycode == KeyCode.PAGE_UP) { return "Pageup"; } if (keycode == KeyCode.PAGE_DOWN) { return "Pagedown"; } if (keycode == KeyCode.UP) { return "Up"; } if (keycode == KeyCode.DOWN) { return "Down"; } if (keycode == KeyCode.LEFT) { return "Left"; } if (keycode == KeyCode.RIGHT) { return "Right"; } if (keycode == KeyCode.ENTER) { return "Enter"; } return keycode.getName(); }
Example 8
Source File: WSRecorder.java From marathonv5 with Apache License 2.0 | 4 votes |
private boolean needManualRecording(KeyCode keyCode) { return keyCode == KeyCode.BACK_SPACE || keyCode == KeyCode.DELETE || keyCode == KeyCode.ESCAPE || keyCode == KeyCode.SPACE; }
Example 9
Source File: JavaFxRecorderHook.java From marathonv5 with Apache License 2.0 | 4 votes |
public static String keyEventGetKeyText(KeyCode keyCode) { if (keyCode == KeyCode.TAB) { return "Tab"; } if (keyCode == KeyCode.CONTROL) { return "Ctrl"; } if (keyCode == KeyCode.ALT) { return "Alt"; } if (keyCode == KeyCode.SHIFT) { return "Shift"; } if (keyCode == KeyCode.META) { return "Meta"; } if (keyCode == KeyCode.SPACE) { return "Space"; } if (keyCode == KeyCode.BACK_SPACE) { return "Backspace"; } if (keyCode == KeyCode.HOME) { return "Home"; } if (keyCode == KeyCode.END) { return "End"; } if (keyCode == KeyCode.DELETE) { return "Delete"; } if (keyCode == KeyCode.PAGE_UP) { return "Pageup"; } if (keyCode == KeyCode.PAGE_DOWN) { return "Pagedown"; } if (keyCode == KeyCode.UP) { return "Up"; } if (keyCode == KeyCode.DOWN) { return "Down"; } if (keyCode == KeyCode.LEFT) { return "Left"; } if (keyCode == KeyCode.RIGHT) { return "Right"; } if (keyCode == KeyCode.ENTER) { return "Enter"; } return keyCode.getName(); }
Example 10
Source File: CreateNewAccount.java From ChatRoomFX with MIT License | 4 votes |
@FXML private void intRestriction(KeyEvent key){ if(!"0123456789".contains(key.getCharacter())&&(key.getCode()!= KeyCode.BACK_SPACE)){ key.consume(); } }
Example 11
Source File: StreamPropertiesViewController.java From trex-stateless-gui with Apache License 2.0 | 4 votes |
@Override public void handle(KeyEvent event) { if (!event.getCharacter().matches("[0-9]") && event.getCode() != KeyCode.BACK_SPACE) { event.consume(); } }
Example 12
Source File: Text.java From CircuitSim with BSD 3-Clause "New" or "Revised" License | 4 votes |
@Override public boolean keyPressed(CircuitManager manager, CircuitState state, KeyCode keyCode, String text) { return keyCode == KeyCode.BACK_SPACE && !this.text.isEmpty(); }