javafx.scene.input.KeyCode Java Examples
The following examples show how to use
javafx.scene.input.KeyCode.
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: ResultList.java From iliasDownloaderTool with GNU General Public License v2.0 | 7 votes |
private void handleKeyEvents(KeyEvent event) { if (event.getCode() == KeyCode.DELETE && listMode.equals(ResultListMode.IGNORE_MODE)) { final IliasFile file = (IliasFile) getSelectionModel().getSelectedItem(); Settings.getInstance().toggleFileIgnored(file); dashboard.pdfIgnoredStateChanged(file); pdfIgnoredStateChanged(file); getSelectionModel().selectNext(); } else if (event.getCode() == KeyCode.UP || event.getCode() == KeyCode.DOWN) { final IliasTreeNode selectedDirectory = ((ResultList) event.getSource()) .getSelectionModel().getSelectedItem(); dashboard.getCoursesTreeView().selectFile((IliasFile) selectedDirectory); } else if (event.getCode() == KeyCode.ENTER && Settings.getInstance().getFlags().isUserLoggedIn()) { new Thread(new IliasPdfDownloadCaller(getSelectionModel().getSelectedItem())).start(); } }
Example #2
Source File: DesignerRootImpl.java From pmd-designer with BSD 2-Clause "Simplified" License | 6 votes |
public DesignerRootImpl(Stage mainStage, DesignerParams params, HostServices hostServices) { this.mainStage = mainStage; this.developerMode = params.isDeveloperMode(); registerService(LOGGER, new EventLoggerImpl(this)); // vetoed by any other key press, so that eg CTRL+V repeatedly vetoes it mainStage.addEventHandler(KeyEvent.KEY_PRESSED, e -> isCtrlDown.setValue( e.isControlDown() && e.getCode() == KeyCode.CONTROL)); mainStage.addEventHandler(KeyEvent.KEY_RELEASED, e -> isCtrlDown.setValue( e.isControlDown() && e.getCode() == KeyCode.CONTROL)); GlobalDiskManagerImpl diskManager = new GlobalDiskManagerImpl(this, params.getSettingsDirectory()); registerService(DISK_MANAGER, diskManager); params.processDefaults(diskManager.defaultAppStateFile()); registerService(HOST_SERVICES, hostServices); registerService(PERSISTENCE_MANAGER, new OnDiskPersistenceManager(this, params.getPersistedInputFile(), params.getPersistedOutputFile())); registerService(NODE_SELECTION_CHANNEL, new MessageChannel<>(Category.SELECTION_EVENT_TRACING)); registerService(LATEST_XPATH, new MessageChannel<>(Category.SELECTION_EVENT_TRACING)); registerService(TEST_LOADER, new MessageChannel<>(Category.TEST_LOADING_EVENT)); registerService(TEST_CREATOR, new TestCreatorService()); registerService(TREE_RENDERER_REGISTRY, new TreeRendererRegistry(this)); registerService(IS_NODE_BEING_DRAGGED, Var.newSimpleVar(false)); }
Example #3
Source File: BaseMaterialEditor3DPart.java From jmonkeybuilder with Apache License 2.0 | 6 votes |
@Override @JmeThread protected void registerActionHandlers(@NotNull final ObjectDictionary<String, BooleanFloatConsumer> actionHandlers) { super.registerActionHandlers(actionHandlers); final T fileEditor = getFileEditor(); actionHandlers.put(KEY_S, (isPressed, tpf) -> fileEditor.handleKeyAction(KeyCode.S, isPressed, isControlDown(), isShiftDown(), isButtonMiddleDown())); actionHandlers.put(KEY_C, (isPressed, tpf) -> fileEditor.handleKeyAction(KeyCode.C, isPressed, isControlDown(), isShiftDown(), isButtonMiddleDown())); actionHandlers.put(KEY_P, (isPressed, tpf) -> fileEditor.handleKeyAction(KeyCode.P, isPressed, isControlDown(), isShiftDown(), isButtonMiddleDown())); actionHandlers.put(KEY_L, (isPressed, tpf) -> fileEditor.handleKeyAction(KeyCode.L, isPressed, isControlDown(), isShiftDown(), isButtonMiddleDown())); }
Example #4
Source File: EcoController.java From BetonQuest-Editor with GNU General Public License v3.0 | 6 votes |
private void keyAction(KeyEvent event, Action add, Action edit, Action delete) { if (event.getCode() == KeyCode.DELETE) { if (delete != null) { delete.act(); } event.consume(); return; } if (event.getCode() == KeyCode.ENTER) { if (edit != null) { edit.act(); } event.consume(); return; } KeyCombination combintation = new KeyCodeCombination(KeyCode.N, KeyCombination.CONTROL_DOWN); if (combintation.match(event)) { if (add != null) { add.act(); } event.consume(); return; } }
Example #5
Source File: CodePane.java From JRemapper with MIT License | 6 votes |
/** * Update the current selected class. * * @param c * The newly selected class. */ private void updateSelection(CDec c) { selectedDec = c; info.getChildren().clear(); info.add(new Label("Class name"), 0, 0); TextField name = new TextField(); if (c.hasMappings()) { name.setText(c.map().getCurrentName()); } else { name.setText(c.getFullName()); name.setEditable(false); } if (c.isLocked()) name.setDisable(true); info.add(name, 1, 0); name.addEventHandler(KeyEvent.KEY_PRESSED, (KeyEvent e) -> { if (KeyCode.ENTER == e.getCode()) { pass = -2; c.map().setCurrentName(name.getText()); refreshCode(); resetSelection(); updateStyleAndRegions(); } }); }
Example #6
Source File: ConversationController.java From BetonQuest-Editor with GNU General Public License v3.0 | 6 votes |
private void keyAction(KeyEvent event, Action add, Action edit, Action delete) { if (event.getCode() == KeyCode.DELETE) { if (delete != null) { delete.act(); } event.consume(); return; } if (event.getCode() == KeyCode.ENTER) { if (edit != null) { edit.act(); } event.consume(); return; } KeyCombination combintation = new KeyCodeCombination(KeyCode.N, KeyCombination.CONTROL_DOWN); if (combintation.match(event)) { if (add != null) { add.act(); } event.consume(); return; } }
Example #7
Source File: DatePickerTableCell.java From tornadofx-controls with Apache License 2.0 | 6 votes |
private void createDatePicker() { datePicker = new DatePicker(getItem()); datePicker.converterProperty().bind(converterProperty()); datePicker.setOnAction(event -> { commitEdit(datePicker.getValue()); event.consume(); }); datePicker.setOnKeyReleased(t -> { if (t.getCode() == KeyCode.ESCAPE) { cancelEdit(); t.consume(); } }); }
Example #8
Source File: RecordingListController.java From archivo with GNU General Public License v3.0 | 6 votes |
/** * When the text in the search field changes, check whether we should show the entire recording list or just * a subset. If a subset, start a timer so that we don't keep filtering while the user is still typing, and cancel * any existing timers. When the timer elapses, perform the filtering. */ @FXML public void searchFieldChanged(KeyEvent event) { if (event.getCode() == KeyCode.ESCAPE) { hideSearchBar(null); } else { String search = searchField.getText(); if (search.isEmpty()) { showAllRecordings(); } else { if (filterTimer != null) { filterTimer.cancel(); } filterTimer = new Timer(); filterTimer.schedule(new TimerTask() { @Override public void run() { Platform.runLater(() -> onlyShowMatchingRecordings(search)); } }, FILTER_AFTER_MS); } } }
Example #9
Source File: MenuApp.java From mars-sim with GNU General Public License v3.0 | 6 votes |
/** * Sets up the menu choice */ public void setupMenuData() { menuChoice = Arrays.asList( new Pair<String, Runnable>("New Sim", () -> setupModeChoice()),// mainMenu.runNew(isFXGL)), new Pair<String, Runnable>("Load Sim", () -> mainMenu.runLoad(isFXGL)), //new Pair<String, Runnable>("Multiplayer", () -> {}), new Pair<String, Runnable>("Tutorial", () -> {}), new Pair<String, Runnable>("Benchmark", () -> {}), new Pair<String, Runnable>("Settings", () -> mainMenu.runSettings()), new Pair<String, Runnable>("Credits", () -> {}), new Pair<String, Runnable>("Exit", () -> { //Platform::exit if (isFXGL) { Input input = FXGL.getInput(); input.mockKeyPress(KeyCode.ESCAPE); input.mockKeyRelease(KeyCode.ESCAPE); } else { MainMenu.dialogOnExit(mainMenu.getPane()); } }) ); }
Example #10
Source File: EventQueueDeviceKBTest.java From marathonv5 with Apache License 2.0 | 6 votes |
public void testPressAndReleaseKeys_withAlt() { kss.clear(); driver.pressKey(textField, JavaAgentKeys.ALT); driver.pressKey(textField, JavaAgentKeys.F1); driver.releaseKey(textField, JavaAgentKeys.F1); driver.releaseKey(textField, JavaAgentKeys.ALT); List<String> list = Arrays.asList("Alt pressed " + KeyCode.getKeyCode("Alt"), "Alt pressed " + KeyCode.getKeyCode("F1"), "Alt released " + KeyCode.getKeyCode("F1"), "released " + KeyCode.getKeyCode("Alt")); final String expected = list.toString(); new WaitWithoutException() { @Override public boolean until() { return expected.equals(kss.toString()); } }.wait("List is empty", 3000, 500); AssertJUnit.assertEquals(expected, kss.toString()); }
Example #11
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 #12
Source File: SplitOptionsPaneTest.java From pdfsam with GNU Affero General Public License v3.0 | 5 votes |
@Test public void applyError() { clickOn("#sizeField").write("Chuck").push(KeyCode.ENTER); victim.apply(builder, onError); verify(onError).accept(anyString()); verify(builder, never()).size(anyLong()); }
Example #13
Source File: SplitOptionsPaneTest.java From pdfsam with GNU Affero General Public License v3.0 | 5 votes |
@Test public void reset() { SizeUnitRadio kilo = lookup("#unit" + SizeUnit.KILOBYTE.symbol()).queryAs(SizeUnitRadio.class); clickOn("#sizeField").write("100").push(KeyCode.ENTER); clickOn("#unit" + SizeUnit.KILOBYTE.symbol()); TextInputControl field = lookup("#sizeField").queryTextInputControl(); assertEquals("100", field.getText()); assertTrue(kilo.isSelected()); WaitForAsyncUtils.waitForAsyncFx(2000, () -> victim.resetView()); assertEquals("", field.getText()); assertFalse(kilo.isSelected()); }
Example #14
Source File: RTPlot.java From phoebus with Eclipse Public License 1.0 | 5 votes |
/** onKeyPressed */ private void keyPressed(final KeyEvent event) { if (! handle_keys || axisLimitsField.isVisible() ) return; if (event.getCode() == KeyCode.Z) plot.getUndoableActionManager().undoLast(); else if (event.getCode() == KeyCode.Y) plot.getUndoableActionManager().redoLast(); else if (event.getCode() == KeyCode.O) showConfigurationDialog(); else if (event.getCode() == KeyCode.T) showToolbar(! isToolbarVisible()); else if (event.getCode() == KeyCode.C) toolbar.toggleCrosshair(); else if (event.getCode() == KeyCode.L) plot.showLegend(! plot.isLegendVisible()); else if (event.getCode() == KeyCode.S) plot.stagger(true); else if (event.getCode() == KeyCode.A) plot.enableAutoScale(); else if (event.isControlDown()) toolbar.selectMouseMode(MouseMode.ZOOM_IN); else if (event.isAltDown()) toolbar.selectMouseMode(MouseMode.ZOOM_OUT); else if (event.isShiftDown()) toolbar.selectMouseMode(MouseMode.PAN); else toolbar.selectMouseMode(MouseMode.NONE); event.consume(); }
Example #15
Source File: DockPane.java From phoebus with Eclipse Public License 1.0 | 5 votes |
/** Handle key presses of global significance like Ctrl-S to save */ private void handleGlobalKeys(final KeyEvent event) { // Check for Ctrl (Windows, Linux) resp. Command (Mac) if (! event.isShortcutDown()) return; final DockItem item = (DockItem) getSelectionModel().getSelectedItem(); if (item == null) return; final KeyCode key = event.getCode(); if (key == KeyCode.S) { if (item instanceof DockItemWithInput) { final DockItemWithInput active_item_with_input = (DockItemWithInput) item; if (active_item_with_input.isDirty()) JobManager.schedule(Messages.Save, monitor -> active_item_with_input.save(monitor)); } event.consume(); } else if (key == KeyCode.W) { if (!isFixed()) item.close(); event.consume(); } }
Example #16
Source File: EventResolverController.java From OEE-Designer with MIT License | 5 votes |
public void initialize(DesignerApplication app, EventResolver resolver) throws Exception { // script engine scriptEngine = new ScriptEngineManager().getEngineByName(EquipmentEventResolver.SCRIPT_ENGINE_NAME); // main app setApp(app); // button images setImages(); // script resolver setResolver(resolver); // insert 4 spaces instead of a 8 char tab taScript.addEventFilter(KeyEvent.KEY_PRESSED, new EventHandler<KeyEvent>() { final KeyCombination combo = new KeyCodeCombination(KeyCode.TAB); @Override public void handle(KeyEvent event) { // check for only tab key if (combo.match(event)) { taScript.insertText(taScript.getCaretPosition(), " "); event.consume(); } } }); }
Example #17
Source File: StringBasedArrayPropertyControl.java From jmonkeybuilder with Apache License 2.0 | 5 votes |
/** * Update the value. */ @FxThread protected void updateValue(@Nullable KeyEvent event) { if (!isIgnoreListener() && (event == null || event.getCode() == KeyCode.ENTER)) { apply(); } }
Example #18
Source File: ValidableTextFieldTest.java From pdfsam with GNU Affero General Public License v3.0 | 5 votes |
@Test public void invalidCssNotApplied() { victim.setEnableInvalidStyle(false); clickOn(victim); // focus lost push(KeyCode.TAB); verifyThat(victim, (v) -> !v.getStyleClass().containsAll(Arrays.asList(Style.INVALID.css()))); }
Example #19
Source File: ChatShowPane.java From oim-fx with MIT License | 5 votes |
@SuppressWarnings("unchecked") public KeyEvent createKeyEvent( EventType<? extends KeyEvent> eventType, KeyCode code, String character, String text, boolean shiftDown, boolean controlDown, boolean altDown, boolean metaDown) { return new KeyEvent((EventType<KeyEvent>) eventType, character, text, code, shiftDown, controlDown, altDown, metaDown); }
Example #20
Source File: ChatShowPane.java From oim-fx with MIT License | 5 votes |
private void initContextMenu() { MenuItem mi = new MenuItem("复制"); mi.setOnAction(a -> { KeyEvent ke = createKeyEvent(KeyEvent.KEY_PRESSED, KeyCode.C, "", "", false, true, false, false); processKeyEvent(ke); ke = createKeyEvent(KeyEvent.KEY_RELEASED, KeyCode.C, "", "", false, true, false, false); processKeyEvent(ke); }); contextMenu.getItems().add(mi); }
Example #21
Source File: SendPrivateNotificationWindow.java From bisq with GNU Affero General Public License v3.0 | 5 votes |
@Override protected void setupKeyHandler(Scene scene) { if (!hideCloseButton) { scene.setOnKeyPressed(e -> { if (e.getCode() == KeyCode.ESCAPE) { e.consume(); doClose(); } }); } }
Example #22
Source File: MainPageLineEditController.java From BetonQuest-Editor with GNU General Public License v3.0 | 5 votes |
public static boolean display(MainPageLine line) { try { MainPageLineEditController controller = (MainPageLineEditController) BetonQuestEditor .createWindow("view/window/MainPageLineEditWindow.fxml", "edit-main-page-line", 400, 300); if (controller == null) { return false; } controller.stage = (Stage) controller.root.getScene().getWindow(); controller.line = line; controller.id.setText(line.getId().get()); controller.text.setText(line.getText().get().get()); controller.conditionList = FXCollections.observableArrayList(line.getConditions()); controller.priority.setText(String.valueOf(line.getPriority().get())); controller.root.getScene().addEventFilter(KeyEvent.KEY_PRESSED, event -> { if (event.getCode() == KeyCode.ESCAPE) { controller.cancel(); event.consume(); return; } if (event.getCode() == KeyCode.ENTER) { controller.ok(); event.consume(); return; } }); controller.refresh(); controller.stage.showAndWait(); return controller.result; } catch (Exception e) { ExceptionController.display(e); return false; } }
Example #23
Source File: PasswordFieldPopupTest.java From pdfsam with GNU Affero General Public License v3.0 | 5 votes |
@Test public void pwdSentOnEnterKey() { clickOn("press"); Listener<PdfLoadRequestEvent> listener = mock(Listener.class); eventStudio().add(PdfLoadRequestEvent.class, listener); write("myPwd").type(KeyCode.ENTER); verify(listener).onEvent(any()); verify(pdfDescriptor).setPassword("myPwd"); }
Example #24
Source File: ExtractOptionsPaneTest.java From pdfsam with GNU Affero General Public License v3.0 | 5 votes |
@Test public void validSteps() { clickOn("#extractRanges").type(KeyCode.DIGIT5).push(KeyCode.ENTER); victim.apply(builder, onError); verify(builder).ranges(anySet()); verify(onError, never()).accept(anyString()); }
Example #25
Source File: PreferencesStage.java From marathonv5 with Apache License 2.0 | 5 votes |
protected void onKeyPressed(KeyEvent e) { if (e.getCode() == KeyCode.CONTROL || e.getCode() == KeyCode.SHIFT || e.getCode() == KeyCode.ALT || e.getCode() == KeyCode.META) { return; } String keyText = OSFXUtils.isModifiers(e) ? OSFXUtils.ketEventGetModifiersExText(e) + "+" : ""; keyText += OSFXUtils.keyEventGetKeyText(e.getCode()); keyTriggerField.setText(keyText); }
Example #26
Source File: BookmarksLevelComboBoxTest.java From pdfsam with GNU Affero General Public License v3.0 | 5 votes |
@Test public void invalidIntegerValue() { victim.setValidBookmarkLevels(validLevels); assertEquals(ValidationState.NOT_VALIDATED, victim.getValidationState()); clickOn(victim).write("Chuck").push(KeyCode.ENTER); assertEquals(ValidationState.INVALID, victim.getValidationState()); Arrays.stream(Style.INVALID.css()).forEach((s) -> assertFalse(lookup("." + s).tryQuery().isEmpty())); }
Example #27
Source File: StringPropertyControl.java From jmonkeybuilder with Apache License 2.0 | 5 votes |
/** * Update the value. */ @FxThread private void updateValue(@NotNull KeyEvent event) { if (!isIgnoreListener() && event.getCode() == KeyCode.ENTER) { apply(); } }
Example #28
Source File: TestExporter.java From latexdraw with GNU General Public License v3.0 | 5 votes |
@Test public void testExportTemplateNotExits() { Cmds.of(addRec, selectAllShapes, () -> clickOn(exporter.exportMenu), () -> clickOn("#exportTemplateMenu"), () -> write("fooo2"), () -> type(KeyCode.ENTER), () -> type(KeyCode.ENTER)).execute(); assertEquals(2, CommandsRegistry.getInstance().getCommands().size()); assertTrue(CommandsRegistry.getInstance().getCommands().get(1) instanceof ExportTemplate); }
Example #29
Source File: AttributeEditorPanel.java From constellation with Apache License 2.0 | 5 votes |
/** * multi value pane showing multiple values for an attribute * * @param attribute * @param attributePane * @param values */ private void createMultiValuePane(final AttributeData attribute, final TitledPane attributePane, final Object[] values) { final VBox dataAndMoreButtonBox = new VBox(5); // 5 = spacing final ScrollPane multiValuePane = new ScrollPane(); multiValuePane.setFitToWidth(true); final ObservableList<Object> listData = FXCollections.observableArrayList(); if (values.length > VISIBLE_ROWS) { for (int i = 0; i < VISIBLE_ROWS; i++) { listData.add(values[i]); } } else { listData.addAll(values); } final ListView<Object> listView = createListView(attribute, listData); final boolean moreToLoad = values.length > VISIBLE_ROWS; int visibleRow = moreToLoad ? VISIBLE_ROWS : listData.size(); listView.setPrefHeight((CELL_HEIGHT * visibleRow) + 2); // +2 because if it is == then there is still a scrollbar. multiValuePane.setPrefHeight((CELL_HEIGHT * visibleRow) + 1); multiValuePane.setContent(listView); multiValuePane.setVbarPolicy(ScrollPane.ScrollBarPolicy.NEVER); dataAndMoreButtonBox.setAlignment(Pos.CENTER); dataAndMoreButtonBox.setPadding(new Insets(0, 0, 5, 0)); dataAndMoreButtonBox.getChildren().add(multiValuePane); if (moreToLoad) { Button loadMoreButton = createLoadMoreButton(dataAndMoreButtonBox, attribute); dataAndMoreButtonBox.getChildren().add(loadMoreButton); } dataAndMoreButtonBox.addEventFilter(KeyEvent.KEY_PRESSED, (KeyEvent event) -> { if (event.isShortcutDown() && (event.getCode() == KeyCode.A)) { listView.getSelectionModel().selectAll(); event.consume(); } }); attributePane.setContent(dataAndMoreButtonBox); }
Example #30
Source File: ChatController.java From ChatFX with MIT License | 5 votes |
@Override public void initialize(URL url, ResourceBundle rb) { root.setOnKeyPressed(e -> { if (e.getCode().equals(KeyCode.ENTER)) { sendMsg(); } }); }