javafx.scene.input.KeyEvent Java Examples

The following examples show how to use javafx.scene.input.KeyEvent. 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: MyBoxLanguagesController.java    From MyBox with Apache License 2.0 6 votes vote down vote up
@Override
public void controlHandler(KeyEvent event) {
    super.controlHandler(event);
    if (!event.isControlDown()) {
        return;
    }
    String key = event.getText();
    if (key == null || key.isEmpty()) {
        return;
    }
    switch (key) {
        case "e":
        case "E":
            copyEnglish();
            return;

    }
}
 
Example #2
Source File: MarketView.java    From bisq with GNU Affero General Public License v3.0 6 votes vote down vote up
@Override
protected void activate() {
    root.getSelectionModel().selectedItemProperty().addListener(tabChangeListener);
    navigation.addListener(navigationListener);

    if (root.getSelectionModel().getSelectedItem() == offerBookTab)
        navigation.navigateTo(MainView.class, MarketView.class, OfferBookChartView.class);
    else if (root.getSelectionModel().getSelectedItem() == tradesTab)
        navigation.navigateTo(MainView.class, MarketView.class, TradesChartsView.class);
    else
        navigation.navigateTo(MainView.class, MarketView.class, SpreadView.class);

    if (root.getScene() != null) {
        scene = root.getScene();
        scene.addEventHandler(KeyEvent.KEY_RELEASED, keyEventEventHandler);
    }
}
 
Example #3
Source File: DesignerRootImpl.java    From pmd-designer with BSD 2-Clause "Simplified" License 6 votes vote down vote up
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 #4
Source File: EditingStrCell.java    From CPUSim with GNU General Public License v3.0 6 votes vote down vote up
/**
 * creates a text field with listeners so that that edits will be committed 
 * at the proper time
 */
protected void createTextField() {
    textField = new TextField(getString());
    textField.setMinWidth(this.getWidth() - this.getGraphicTextGap() * 2);
    textField.focusedProperty().addListener(new ChangeListener<Boolean>() {
        @Override
        public void changed(ObservableValue<? extends Boolean> arg0,
                            Boolean arg1, Boolean arg2) {
            if (!arg2) {
                commitEdit(textField.getText());
            }
        }
    });
    textField.setOnKeyPressed(new EventHandler<KeyEvent>() {
        @Override
        public void handle(KeyEvent t) {
            if (t.getCode() == KeyCode.ENTER) {
                commitEdit(textField.getText());
            } else if (t.getCode() == KeyCode.ESCAPE) {
                cancelEdit();
            }
        }
    });
}
 
Example #5
Source File: JFXKey.java    From tuxguitar with GNU Lesser General Public License v2.1 6 votes vote down vote up
public static UIKeyCombination getCombination(KeyEvent keyEvent) {
	UIKeyCombination keyCombination = new UIKeyCombination();
	if( keyEvent.isAltDown() ) {
		keyCombination.getKeys().add(UIKey.ALT);
	}
	if( keyEvent.isShiftDown() ) {
		keyCombination.getKeys().add(UIKey.SHIFT);
	}
	if( keyEvent.isControlDown() ) {
		keyCombination.getKeys().add(UIKey.CONTROL);
	}
	if( keyEvent.isMetaDown() ) {
		keyCombination.getKeys().add(UIKey.COMMAND);
	}
	
	UIKey principalKey = JFXKey.getKey(keyEvent);
	if(!keyCombination.contains(principalKey)) {
		keyCombination.getKeys().add(principalKey);
	}
	
	return keyCombination;
}
 
Example #6
Source File: ImageManufactureController.java    From MyBox with Apache License 2.0 6 votes vote down vote up
@Override
public void altHandler(KeyEvent event) {
    super.altHandler(event);
    if (event.isAltDown()) {
        String key = event.getText();
        if (key == null || key.isEmpty()) {
            return;
        }
        switch (key) {
            case "p":
            case "P":
                if (!popButton.isDisabled()) {
                    popAction();
                }
                break;
            default:
                break;
        }
    }
}
 
Example #7
Source File: Dialog.java    From LogFX with GNU General Public License v3.0 6 votes vote down vote up
public Dialog( String stylesheet, Node top, Node... others ) {
    dialogStage.initOwner( primaryStage );
    dialogStage.initModality( Modality.NONE );
    box.setAlignment( Pos.CENTER );
    box.setPadding( new Insets( 20 ) );
    box.getChildren().add( top );
    box.getChildren().addAll( others );
    dialogStage.setScene( new Scene( box ) );
    dialogStage.getScene().setFill( Color.TRANSPARENT );
    dialogStage.addEventHandler( KeyEvent.KEY_RELEASED, ( KeyEvent event ) -> {
        if ( KeyCode.ESCAPE == event.getCode() ) {
            dialogStage.close();
        }
    } );

    if ( stylesheet == null ) {
        FxUtils.setupStylesheet( dialogStage.getScene() );
    } else {
        dialogStage.getScene().getStylesheets().add( stylesheet );
    }
}
 
Example #8
Source File: PanOnStrokeHandler.java    From gef with Eclipse Public License 2.0 6 votes vote down vote up
@Override
public void finalRelease(KeyEvent event) {
	if (invalidGesture) {
		return;
	}

	updateMillisOnKeyRelease(event);

	timer.stop();
	updateScrollPosition();
	commit(viewportPolicy);
	viewportPolicy = null;
	totalMillisDown = 0;
	totalMillisUp = 0;
	totalMillisLeft = 0;
	totalMillisRight = 0;
}
 
Example #9
Source File: ImagePanel.java    From Quelea with GNU General Public License v3.0 6 votes vote down vote up
/**
 * Create a new image panel.
 */
public ImagePanel() {
    setStyle("-fx-background-color: rgba(0, 0, 0);");
    previewCanvas = new DisplayCanvas(false, false, false, super::updateCanvas, Priority.LOW);
    registerDisplayCanvas(previewCanvas);
    setCenter(previewCanvas);
    addEventFilter(KeyEvent.KEY_PRESSED, (KeyEvent t) -> {
        if (t.getCode().equals(KeyCode.PAGE_DOWN) || t.getCode().equals(KeyCode.DOWN)) {
            t.consume();
            QueleaApp.get().getMainWindow().getMainPanel().getLivePanel().advance();
        } else if (t.getCode().equals(KeyCode.PAGE_UP) || t.getCode().equals(KeyCode.UP)) {
            t.consume();
            QueleaApp.get().getMainWindow().getMainPanel().getLivePanel().previous();
        }
    });
}
 
Example #10
Source File: GenericStyledAreaBehavior.java    From RichTextFX with BSD 2-Clause "Simplified" License 5 votes vote down vote up
private void right(KeyEvent ignore) {
    IndexRange sel = view.getSelection();
    if(sel.getLength() == 0) {
        view.nextChar(SelectionPolicy.CLEAR);
    } else {
        view.moveTo(sel.getEnd(), SelectionPolicy.CLEAR);
    }
}
 
Example #11
Source File: InstructionEditController.java    From BetonQuest-Editor with GNU General Public License v3.0 5 votes vote down vote up
/**
 * Displays a window in which the user can edit the Instruction object.
 * 
 * @param data the Instruction object to edit
 */
public static boolean display(Instruction data) {
	try {
		InstructionEditController controller = (InstructionEditController) BetonQuestEditor
				.createWindow("view/window/InstructionEditWindow.fxml", "edit-instruction", 500, 150);
		if (controller == null) {
			return false;
		}
		controller.stage = (Stage) controller.root.getScene().getWindow();
		controller.data = data;
		controller.id.setText(data.getId().get());
		controller.instruction.setText(data.getInstruction().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.stage.showAndWait();
		return controller.result;
	} catch (Exception e) {
		ExceptionController.display(e);
		return false;
	}
}
 
Example #12
Source File: SortedChoiceController.java    From BetonQuest-Editor with GNU General Public License v3.0 5 votes vote down vote up
public static <O extends ID, W extends IdWrapper<O>, F extends ListCell<W>> void display(
		String labelText,
		ObservableList<W> chosen,
		ObservableList<O> available,
		Creator<O> creator,
		CellFactory<F> cellFactory,
		Wrapper<O, W> wrapper,
		Refresher refresher
) {
	try {
		@SuppressWarnings("unchecked")
		SortedChoiceController<O, W, F> controller = (SortedChoiceController<O, W, F>) BetonQuestEditor
				.createWindow("view/window/SortedChoiceWindow.fxml", "choose-objects", 400, 500);
		if (controller == null) {
			return;
		}
		controller.stage = (Stage) controller.root.getScene().getWindow();
		controller.labelText = labelText;
		controller.chosen = chosen;
		controller.available = available;
		controller.creator = creator;
		controller.cellFactory = cellFactory;
		controller.wrapper = wrapper;
		controller.refresher = refresher;
		controller.stage.setOnCloseRequest(event -> {
			refresher.refresh();
		});
		controller.list.setOnMouseClicked(event -> {
			if (event.getButton() == MouseButton.PRIMARY && event.getClickCount() == 2) {
				controller.edit();
			}
		});
		controller.root.getScene().addEventFilter(KeyEvent.KEY_PRESSED, event -> controller.key(event));
		controller.refresh(); // fill the view
		controller.stage.showAndWait();
	} catch (Exception e) {
		ExceptionController.display(e);
	}
}
 
Example #13
Source File: OtherController.java    From BetonQuest-Editor with GNU General Public License v3.0 5 votes vote down vote up
@FXML public void journalKey(KeyEvent event) {
	try {
		keyAction(event, () -> addEntry(), () -> editEntry(), () -> delEntry());
	} catch (Exception e) {
		ExceptionController.display(e);
	}
}
 
Example #14
Source File: FileViewport.java    From Recaf with MIT License 5 votes vote down vote up
@Override
protected void handleKeyReleased(KeyEvent e) {
	super.handleKeyReleased(e);
	// Custom bind support
	PluginKeybinds.getInstance().getFileViewBinds().forEach((bind, action) -> {
		try {
			if (bind.match(e))
				action.accept(this);
		} catch(Throwable t) {
			Log.error(t, "Failed executing file keybind action");
		}
	});
}
 
Example #15
Source File: SettingsDialog.java    From mdict-java with GNU General Public License v3.0 5 votes vote down vote up
public SettingsDialog(javafx.stage.Stage owner, PlainDictAppOptions _opt, ResourceBundle _bundle)
{
	super();
	opt=_opt;
	bundle=_bundle;
	setTitle(bundle.getString(UI.settings));
	getIcons().add(new Image(HiddenSplitPaneApp.class.getResourceAsStream("shared-resources/settings.png")));
	addEventFilter(KeyEvent.KEY_PRESSED, new EventHandler<KeyEvent>() {
		public void handle(KeyEvent e) {
			if (EscComb.match(e)) {
				hide();
				e.consume();
			}
		}
	});
	content = new VBox(make_switchable_path_picker(true, UI.overwrite_browser,opt.getBrowserPathOverwrite(), opt.GetBrowserPathOverwriteEnabled())
		, make_switchable_path_picker(true, UI.overwrite_browser_search,opt.GetSearchUrlOverwrite(), opt.GetSearchUrlOverwriteEnabled())
		, make_switchable_path_picker(false, UI.overwrite_browser_search1,opt.getSearchUrlMiddle(), false)
		, make_switchable_path_picker(false, UI.overwrite_browser_search2,opt.getSearchUrlRight(), false)
		, make_switchable_path_picker(false, UI.ow_bsrarg,opt.getBrowserArgs(), false)
		, make_switchable_path_picker(true, UI.overwrite_pdf_reader,opt.GetPdfOverwrite(), opt.GetPdfOverwriteEnabled())
		, make_switchable_path_picker(true, UI.overwrite_pdf_reader_args,opt.GetPdfArgsOverwrite(), opt.GetPdfArgsOverwriteEnabled())
		, make_simple_buttons(UI.pdffolders, regex_config)
		, make_simple_seperator()
		, make_3_simple_switcher(bundle,this, regex_enable, opt.GetRegexSearchEngineEnabled(), ps_regex, opt.GetPageSearchUseRegex(), class_case, opt.GetClassicalKeyCaseStrategy())
		, make_3_simple_switcher(bundle,this, tintwild, opt.GetTintWildResult(), remwsize, opt.GetRemWindowSize(), remwpos, opt.GetRemWindowPos())
		, make_3_simple_switcher(bundle,this, tintfull, opt.GetTintFullResult(), doclsset, opt.GetDoubleClickCloseSet(), doclsdict, opt.GetDoubleClickCloseDict())
		, make_simple_seperator()
		, make_3_simple_switcher(bundle,this, dt_dictpic, opt.GetDetachDictPicker(), dt_advsrch, opt.GetDetachAdvSearch(), dt_setting, opt.GetDetachSettings())
		, make_simple_seperator()
		, make_3_simple_switcher(bundle,this, autopaste, opt.GetAutoPaste(), filterpaste, opt.GetFilterPaste(), Toodoo, false)
		, make_simple_seperator()

	);
	ScrollPane sv = new ScrollPane(content);
	sv.setFitToWidth(true);
	Scene Scene = new Scene(sv, 800, 600);
	setScene(Scene);
}
 
Example #16
Source File: MainViewController.java    From trex-stateless-gui with Apache License 2.0 5 votes vote down vote up
/**
 * 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 #17
Source File: EditorDialog.java    From jmonkeybuilder with Apache License 2.0 5 votes vote down vote up
/**
 * Process key.
 *
 * @param event the event
 */
@FxThread
protected void processKey(@NotNull KeyEvent event) {
    event.consume();
    if (event.getCode() == KeyCode.ESCAPE) {
        hide();
    }
}
 
Example #18
Source File: OtherController.java    From BetonQuest-Editor with GNU General Public License v3.0 5 votes vote down vote up
@FXML public void itemKey(KeyEvent event) {
	try {
		keyAction(event, () -> addItem(), () -> renameItem(), () -> delItem());
	} catch (Exception e) {
		ExceptionController.display(e);
	}
}
 
Example #19
Source File: AutocompleteMenu.java    From phoebus with Eclipse Public License 1.0 5 votes vote down vote up
/** Attach the completion menu to a text field
 *
 *  @param field Field for which completion is requested
 */
public void attachField(final TextInputControl field)
{
    field.addEventFilter(KeyEvent.KEY_PRESSED, key_pressed_filter);
    field.addEventFilter(KeyEvent.KEY_RELEASED, key_released_filter);
    field.focusedProperty().addListener(focused_listener);
    XPasteBuffer.addMiddleClickPaste(field);
}
 
Example #20
Source File: KeyStrokeMotion.java    From netbeans with Apache License 2.0 5 votes vote down vote up
public LettersPane() {
    setId("LettersPane");
    setPrefSize(480,480);
    setFocusTraversable(true);
    setOnMousePressed(new EventHandler<MouseEvent>() {
        
        @Override public void handle(MouseEvent me) {
            requestFocus();
            me.consume();
        }
    });
    setOnKeyPressed(new EventHandler<KeyEvent>() {
        
        @Override public void handle(KeyEvent ke) {
            createLetter(ke.getText());
            ke.consume();
        }
    });
    // create press keys text
    pressText = new Text("Press Keys");
    pressText.setTextOrigin(VPos.TOP);
    pressText.setFont(new Font(Font.getDefault().getFamily(), 40));
    pressText.setLayoutY(5);
    pressText.setFill(Color.rgb(80, 80, 80));
    DropShadow effect = new DropShadow();
    effect.setRadius(0);
    effect.setOffsetY(1);
    effect.setColor(Color.WHITE);
    pressText.setEffect(effect);
    getChildren().add(pressText);
}
 
Example #21
Source File: PreferencesFxDialog.java    From PreferencesFX with Apache License 2.0 5 votes vote down vote up
private void setupDebugHistoryTable() {
  final KeyCombination keyCombination =
      new KeyCodeCombination(KeyCode.H, KeyCombination.SHORTCUT_DOWN, KeyCombination.SHIFT_DOWN);
  preferencesFxView.getScene().addEventHandler(KeyEvent.KEY_RELEASED, event -> {
    if (keyCombination.match(event)) {
      LOGGER.trace("Opened History Debug View");
      new HistoryDialog(model.getHistory());
    }
  });
}
 
Example #22
Source File: Keyboard.java    From jace with GNU General Public License v2.0 5 votes vote down vote up
public void keyReleased(KeyEvent e) {
    KeyCode code = e.getCode();
    processKeyUpEvents(e);
    if (code == null || e.isConsumed()) {
        return;
    }
    
    e.consume();
}
 
Example #23
Source File: SandboxModeMediator.java    From metastone with GNU General Public License v2.0 5 votes vote down vote up
@Override
public void handle(KeyEvent keyEvent) {
	if (keyEvent.getCode() != KeyCode.ESCAPE) {
		return;
	}

	view.disableTargetSelection();
}
 
Example #24
Source File: BatchController.java    From MyBox with Apache License 2.0 5 votes vote down vote up
@Override
    public void keyEventsHandler(KeyEvent event) {
        super.keyEventsHandler(event);
//        logger.debug(event.getCode() + " " + event.getText());
        if (tableController != null) {
            tableController.keyEventsHandler(event); // pass event to table pane
        }
    }
 
Example #25
Source File: GenericStyledAreaBehavior.java    From RichTextFX with BSD 2-Clause "Simplified" License 5 votes vote down vote up
private void deleteNextWord(KeyEvent ignore) {
    int start = view.getCaretPosition();

    if (start < view.getLength()) {
        view.wordBreaksForwards(2, SelectionPolicy.CLEAR);
        int end = view.getCaretPosition();
        view.replaceText(start, end, "");
    }
}
 
Example #26
Source File: TargetEditorController.java    From ShootOFF with GNU General Public License v3.0 5 votes vote down vote up
@FXML
public void canvasKeyPressed(KeyEvent event) {
	if (freeformButton.isSelected() && event.isControlDown() && event.getCode() == KeyCode.Z) {

		undoPolygonStep();
	}
}
 
Example #27
Source File: CameraController.java    From FXyzLib with GNU General Public License v3.0 5 votes vote down vote up
private void handleKeyEvent(KeyEvent t) {
    if (t.getEventType() == KeyEvent.KEY_PRESSED) {
        handleKeyEvent(t, true);
    } else if (t.getEventType() == KeyEvent.KEY_RELEASED) {
        handleKeyEvent(t, true);
    }
    speed = getSpeedModifier(t);
}
 
Example #28
Source File: FXEventQueueDevice.java    From marathonv5 with Apache License 2.0 5 votes vote down vote up
@Override
public void pressKey(Node node, JavaAgentKeys keyToPress) {
    if (keyToPress == JavaAgentKeys.NULL) {
        resetModifierState(node);
    } else {
        dispatchKeyEvent(node, keyToPress, KeyEvent.KEY_PRESSED, KeyEvent.CHAR_UNDEFINED.charAt(0));
    }

}
 
Example #29
Source File: QuaternionPropertyControl.java    From jmonkeybuilder with Apache License 2.0 5 votes vote down vote up
/**
 * Handle of input the enter key.
 */
@FxThread
private void keyReleased(@NotNull KeyEvent event) {
    if (event.getCode() == KeyCode.ENTER) {
        changeValue();
    }
}
 
Example #30
Source File: RFXComponent.java    From marathonv5 with Apache License 2.0 5 votes vote down vote up
public void handleRawRecording(IJSONRecorder recorder, Event event) {
    if (event instanceof MouseEvent && event.getEventType() == MouseEvent.MOUSE_PRESSED) {
        recorder.recordRawMouseEvent(this, (MouseEvent) event);
    }
    if (event instanceof KeyEvent && event.getEventType() != KeyEvent.KEY_RELEASED) {
        recorder.recordRawKeyEvent(this, (KeyEvent) event);
    }
}