Example usage for javafx.scene.input KeyEvent isAltDown

List of usage examples for javafx.scene.input KeyEvent isAltDown

Introduction

In this page you can find the example usage for javafx.scene.input KeyEvent isAltDown.

Prototype

public final boolean isAltDown() 

Source Link

Document

Returns whether or not the Alt modifier is down on this event.

Usage

From source file:Main.java

private static int modifiers(final InputEvent event) {
    if (event instanceof MouseEvent) {
        final MouseEvent mouseEvent = (MouseEvent) event;
        int modifiers = 0;
        if (mouseEvent.isAltDown()) {
            modifiers |= java.awt.event.MouseEvent.ALT_MASK;
            modifiers |= java.awt.event.MouseEvent.ALT_DOWN_MASK;
        }//from  w  ww  . j  a v a  2 s.co  m
        if (mouseEvent.isControlDown()) {
            modifiers |= java.awt.event.MouseEvent.CTRL_MASK;
            modifiers |= java.awt.event.MouseEvent.CTRL_DOWN_MASK;
        }
        if (mouseEvent.isMetaDown()) {
            modifiers |= java.awt.event.MouseEvent.META_MASK;
            modifiers |= java.awt.event.MouseEvent.META_DOWN_MASK;
        }
        if (mouseEvent.isShiftDown()) {
            modifiers |= java.awt.event.MouseEvent.SHIFT_MASK;
            modifiers |= java.awt.event.MouseEvent.SHIFT_DOWN_MASK;
        }
        if (mouseEvent.isPrimaryButtonDown()) {
            modifiers |= java.awt.event.MouseEvent.BUTTON1_MASK;
        }
        if (mouseEvent.isMiddleButtonDown()) {
            modifiers |= java.awt.event.MouseEvent.BUTTON2_MASK;
        }
        if (mouseEvent.isSecondaryButtonDown()) {
            modifiers |= java.awt.event.MouseEvent.BUTTON3_MASK;
        }
        return modifiers;
    }

    if (event instanceof KeyEvent) {
        final KeyEvent keyEvent = (KeyEvent) event;
        int modifiers = 0;
        if (keyEvent.isAltDown()) {
            modifiers |= java.awt.event.KeyEvent.ALT_MASK;
        }
        if (keyEvent.isControlDown()) {
            modifiers |= java.awt.event.KeyEvent.CTRL_MASK;
        }
        if (keyEvent.isMetaDown()) {
            modifiers |= java.awt.event.KeyEvent.META_MASK;
        }
        if (keyEvent.isShiftDown()) {
            modifiers |= java.awt.event.KeyEvent.SHIFT_MASK;
        }
        return modifiers;
    }

    return 0;
}

From source file:nars.rl.util.ThreeDView.java

private void handleKeyboard(Scene scene, final Node root) {
    final boolean moveCamera = true;
    scene.setOnKeyPressed(new EventHandler<KeyEvent>() {
        @Override/*from w ww .  jav a  2 s  .  c om*/
        public void handle(KeyEvent event) {
            Duration currentTime;
            switch (event.getCode()) {
            case Z:
                if (event.isShiftDown()) {
                    cameraXform.ry.setAngle(0.0);
                    cameraXform.rx.setAngle(0.0);
                    camera.setTranslateZ(-300.0);
                }
                cameraXform2.t.setX(0.0);
                cameraXform2.t.setY(0.0);
                break;
            case X:
                if (event.isControlDown()) {
                    if (axisGroup.isVisible()) {
                        axisGroup.setVisible(false);
                    } else {
                        axisGroup.setVisible(true);
                    }
                }
                break;
            case S:
                if (event.isControlDown()) {
                    if (space.isVisible()) {
                        space.setVisible(false);
                    } else {
                        space.setVisible(true);
                    }
                }
                break;
            case SPACE:
                if (timelinePlaying) {
                    timeline.pause();
                    timelinePlaying = false;
                } else {
                    timeline.play();
                    timelinePlaying = true;
                }
                break;
            case UP:
                if (event.isControlDown() && event.isShiftDown()) {
                    cameraXform2.t.setY(cameraXform2.t.getY() - 10.0 * CONTROL_MULTIPLIER);
                } else if (event.isAltDown() && event.isShiftDown()) {
                    cameraXform.rx.setAngle(cameraXform.rx.getAngle() - 10.0 * ALT_MULTIPLIER);
                } else if (event.isControlDown()) {
                    cameraXform2.t.setY(cameraXform2.t.getY() - 1.0 * CONTROL_MULTIPLIER);
                } else if (event.isAltDown()) {
                    cameraXform.rx.setAngle(cameraXform.rx.getAngle() - 2.0 * ALT_MULTIPLIER);
                } else if (event.isShiftDown()) {
                    double z = camera.getTranslateZ();
                    double newZ = z + 5.0 * SHIFT_MULTIPLIER;
                    camera.setTranslateZ(newZ);
                }
                break;
            case DOWN:
                if (event.isControlDown() && event.isShiftDown()) {
                    cameraXform2.t.setY(cameraXform2.t.getY() + 10.0 * CONTROL_MULTIPLIER);
                } else if (event.isAltDown() && event.isShiftDown()) {
                    cameraXform.rx.setAngle(cameraXform.rx.getAngle() + 10.0 * ALT_MULTIPLIER);
                } else if (event.isControlDown()) {
                    cameraXform2.t.setY(cameraXform2.t.getY() + 1.0 * CONTROL_MULTIPLIER);
                } else if (event.isAltDown()) {
                    cameraXform.rx.setAngle(cameraXform.rx.getAngle() + 2.0 * ALT_MULTIPLIER);
                } else if (event.isShiftDown()) {
                    double z = camera.getTranslateZ();
                    double newZ = z - 5.0 * SHIFT_MULTIPLIER;
                    camera.setTranslateZ(newZ);
                }
                break;
            case RIGHT:
                if (event.isControlDown() && event.isShiftDown()) {
                    cameraXform2.t.setX(cameraXform2.t.getX() + 10.0 * CONTROL_MULTIPLIER);
                } else if (event.isAltDown() && event.isShiftDown()) {
                    cameraXform.ry.setAngle(cameraXform.ry.getAngle() - 10.0 * ALT_MULTIPLIER);
                } else if (event.isControlDown()) {
                    cameraXform2.t.setX(cameraXform2.t.getX() + 1.0 * CONTROL_MULTIPLIER);
                } else if (event.isAltDown()) {
                    cameraXform.ry.setAngle(cameraXform.ry.getAngle() - 2.0 * ALT_MULTIPLIER);
                }
                break;
            case LEFT:
                if (event.isControlDown() && event.isShiftDown()) {
                    cameraXform2.t.setX(cameraXform2.t.getX() - 10.0 * CONTROL_MULTIPLIER);
                } else if (event.isAltDown() && event.isShiftDown()) {
                    cameraXform.ry.setAngle(cameraXform.ry.getAngle() + 10.0 * ALT_MULTIPLIER); // -
                } else if (event.isControlDown()) {
                    cameraXform2.t.setX(cameraXform2.t.getX() - 1.0 * CONTROL_MULTIPLIER);
                } else if (event.isAltDown()) {
                    cameraXform.ry.setAngle(cameraXform.ry.getAngle() + 2.0 * ALT_MULTIPLIER); // -
                }
                break;
            }
        }
    });
}

From source file:pl.baczkowicz.mqttspy.ui.controllers.NewPublicationController.java

/**
 * Restores message from the key event./*from  ww  w  . j a  va 2 s  .  com*/
 * 
 * @param keyEvent The generated key event
 * @param keyNumber The key number
 */
private void restoreFromKeypress(final KeyEvent keyEvent, final int keyNumber) {
    if (keyEvent.isAltDown()) {
        // 1 means first message (most recent); 2 is second, etc.; 0 is the 10th (the oldest)
        final int arrayIndex = (keyNumber > 0 ? keyNumber : MAX_RECENT_MESSAGES) - 1;

        if (arrayIndex < recentMessages.size()) {
            displayMessage(recentMessages.get(arrayIndex));
        }
        keyEvent.consume();
    }
}