Java Code Examples for javafx.scene.input.KeyCode#LEFT
The following examples show how to use
javafx.scene.input.KeyCode#LEFT .
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: DisplayRuntimeInstance.java From phoebus with Eclipse Public License 1.0 | 5 votes |
/** Handle Alt-left & right as navigation keys */ private void handleKeys(final KeyEvent event) { if (event.isAltDown()) { if (event.getCode() == KeyCode.LEFT && !navigate_backward.isDisabled()) navigate_backward.getOnAction().handle(null); else if (event.getCode() == KeyCode.RIGHT && !navigate_forward.isDisabled()) navigate_forward.getOnAction().handle(null); } }
Example 2
Source File: TestTarget.java From ShootOFF with GNU General Public License v3.0 | 5 votes |
@Test public void testLeftArrowKeyMoveTarget() { double oldX = pepperPopper.getPosition().getX(); double oldY = pepperPopper.getPosition().getY(); KeyEvent leftArrowEvent = new KeyEvent(null, pepperPopper.getTargetGroup(), KeyEvent.KEY_PRESSED, "left", "left", KeyCode.LEFT, false, false, false, false); Event.fireEvent(pepperPopper.getTargetGroup(), leftArrowEvent); assertEquals(oldX - TargetView.MOVEMENT_DELTA, pepperPopper.getPosition().getX(), .001); assertEquals(oldY, pepperPopper.getPosition().getY(), .001); }
Example 3
Source File: TestTarget.java From ShootOFF with GNU General Public License v3.0 | 5 votes |
@Test public void testLeftArrowKeyResizeTarget() { double oldWidth = pepperPopper.getDimension().getWidth(); double oldHeight = pepperPopper.getDimension().getHeight(); KeyEvent leftArrowEvent = new KeyEvent(null, pepperPopper.getTargetGroup(), KeyEvent.KEY_PRESSED, "left", "left", KeyCode.LEFT, true, false, false, false); Event.fireEvent(pepperPopper.getTargetGroup(), leftArrowEvent); assertEquals(oldWidth + TargetView.SCALE_DELTA, pepperPopper.getDimension().getWidth(), .001); assertEquals(oldHeight, pepperPopper.getDimension().getHeight(), .001); }
Example 4
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 5
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 6
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(); }