Java Code Examples for javafx.scene.input.KeyCode#S

The following examples show how to use javafx.scene.input.KeyCode#S . 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: BaseMaterialFileEditor.java    From jmonkeybuilder with Apache License 2.0 6 votes vote down vote up
@Override
@FxThread
protected boolean handleKeyActionImpl(@NotNull final KeyCode keyCode, final boolean isPressed,
                                      final boolean isControlDown, final boolean isShiftDown,
                                      final boolean isButtonMiddleDown) {

    if (isPressed && keyCode == KeyCode.C && !isControlDown && !isButtonMiddleDown) {
        final ToggleButton cubeButton = getCubeButton();
        cubeButton.setSelected(true);
        return true;
    } else if (isPressed && keyCode == KeyCode.S && !isControlDown && !isButtonMiddleDown) {
        final ToggleButton sphereButton = getSphereButton();
        sphereButton.setSelected(true);
        return true;
    } else if (isPressed && keyCode == KeyCode.P && !isControlDown && !isButtonMiddleDown) {
        final ToggleButton planeButton = getPlaneButton();
        planeButton.setSelected(true);
        return true;
    } else if (isPressed && keyCode == KeyCode.L && !isControlDown && !isButtonMiddleDown) {
        final ToggleButton lightButton = getLightButton();
        lightButton.setSelected(!lightButton.isSelected());
        return true;
    }

    return super.handleKeyActionImpl(keyCode, isPressed, isControlDown, isShiftDown, isButtonMiddleDown);
}
 
Example 2
Source File: RTPlot.java    From phoebus with Eclipse Public License 1.0 5 votes vote down vote up
/** 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 3
Source File: DockPane.java    From phoebus with Eclipse Public License 1.0 5 votes vote down vote up
/** 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 4
Source File: AbstractFileEditor.java    From jmonkeybuilder with Apache License 2.0 5 votes vote down vote up
/**
 * Handle the key pressed event.
 *
 * @param event the event
 */
@FxThread
protected void processKeyPressed(@NotNull final KeyEvent event) {

    final KeyCode code = event.getCode();

    if (code == KeyCode.S && event.isControlDown() && isDirty()) {
        save();
    } else if (handleKeyActionImpl(code, true, event.isControlDown(), event.isShiftDown(), false)) {
        event.consume();
    }
}
 
Example 5
Source File: BetonQuestEditor.java    From BetonQuest-Editor with GNU General Public License v3.0 5 votes vote down vote up
private void createPrimaryStage() throws IOException {
	URL location = getClass().getResource("view/Root.fxml");
	Locale locale = Persistence.getSettings().getLanguage();
	language = ResourceBundle.getBundle("pl.betoncraft.betonquest.editor.resource.lang.lang", locale);
	FXMLLoader fxmlLoader = new FXMLLoader(location, language);
	BorderPane root = (BorderPane) fxmlLoader.load();
	TabsController.setDisabled(true);
	Scene scene = new Scene(root, 1280, 720);
	scene.getStylesheets().add(getClass().getResource("resource/style.css").toExternalForm());
	KeyCombination save = new KeyCodeCombination(KeyCode.S, KeyCombination.CONTROL_DOWN);
	KeyCombination export = new KeyCodeCombination(KeyCode.E, KeyCombination.CONTROL_DOWN);
	scene.addEventFilter(KeyEvent.KEY_PRESSED, event -> {
		if (save.match(event)) {
			event.consume();
			MainMenuController.getInstance().save();
		} else if (export.match(event)) {
			event.consume();
			MainMenuController.getInstance().export();
		}
	});
	stage.setScene(scene);
	stage.setTitle(language.getString("betonquest-editor"));
	stage.getIcons().add(new Image(getClass().getResourceAsStream("resource/icon.png")));
	stage.setMinHeight(600);
	stage.setMinWidth(800);
	stage.setMaximized(true);
	stage.show();
}
 
Example 6
Source File: KeyboardExample.java    From JavaFX with MIT License 5 votes vote down vote up
@Override
public void start(final Stage stage) {
	final Keyboard keyboard = new Keyboard(new Key(KeyCode.A), new Key(
			KeyCode.S), new Key(KeyCode.D), new Key(KeyCode.F));

	final Scene scene = new Scene(new Group(keyboard.createNode()));
	stage.setScene(scene);
	stage.setTitle("Keyboard Example");
	stage.show();
}
 
Example 7
Source File: AbstractSceneFileEditor.java    From jmonkeybuilder with Apache License 2.0 4 votes vote down vote up
@Override
@FxThread
protected boolean handleKeyActionImpl(@NotNull final KeyCode keyCode, final boolean isPressed,
                                      final boolean isControlDown, final boolean isShiftDown,
                                      final boolean isButtonMiddleDown) {

    final MA editor3DPart = getEditor3DPart();
    if (editor3DPart.isCameraMoving()) {
        return false;
    }

    if (isPressed && isControlDown && keyCode == KeyCode.Z) {
        undo();
        return true;
    } else if (isPressed && isControlDown && keyCode == KeyCode.Y) {
        redo();
        return true;
    } else if (isPressed && keyCode == KeyCode.G && !isControlDown && !isButtonMiddleDown) {
        final ToggleButton moveToolButton = getMoveToolButton();
        moveToolButton.setSelected(true);
        return true;
    } else if (isPressed && keyCode == KeyCode.R && !isControlDown && !isButtonMiddleDown) {
        final ToggleButton rotationToolButton = getRotationToolButton();
        rotationToolButton.setSelected(true);
        return true;
    } else if (isPressed && keyCode == KeyCode.S && !isControlDown && !isButtonMiddleDown) {
        final ToggleButton scaleToolButton = getScaleToolButton();
        scaleToolButton.setSelected(true);
        return true;
    } else if (isPressed && keyCode == KeyCode.DELETE) {

        final RemoveElementsAction removeAction = findTreeAction(RemoveElementsAction.class);

        if (removeAction == null) {
            return false;
        }

        removeAction.process();
        return true;

    } else if (isPressed && isControlDown && keyCode == KeyCode.C) {
        //TODO
    } else if (isPressed && isControlDown && keyCode == KeyCode.V) {
        //TODO
    }

    return super.handleKeyActionImpl(keyCode, isPressed, isControlDown, isShiftDown, isButtonMiddleDown);
}