Example usage for javafx.scene.input KeyEvent isMetaDown

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

Introduction

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

Prototype

public final boolean isMetaDown() 

Source Link

Document

Returns whether or not the Meta 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  w  w. j a v a  2 s.  com*/
        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;
}