Example usage for java.awt Event META_MASK

List of usage examples for java.awt Event META_MASK

Introduction

In this page you can find the example usage for java.awt Event META_MASK.

Prototype

int META_MASK

To view the source code for java.awt Event META_MASK.

Click Source Link

Document

This flag indicates that the Meta key was down when the event occurred.

Usage

From source file:Main.java

/**
 * gives default modifier of the current OS.
 * //from   w  w w  .  ja v  a 2 s.  c o  m
 * @return meta (command) for OSX, control for Windows/Linux etc 
 */
public static int getSystemDefaultModifier() {
    if (!(UIManager.getLookAndFeel().getID().equals(METAL_LAF_ID))) {
        int mask = Toolkit.getDefaultToolkit().getMenuShortcutKeyMask();
        if (mask == Event.META_MASK) {
            return KeyEvent.VK_META;
        } else if (mask == Event.ALT_MASK) {
            return KeyEvent.VK_ALT;
        }
    }
    return KeyEvent.VK_CONTROL;
}

From source file:EventTester.java

private String mods(int flags) {
    String s = "[ ";
    if (flags == 0)
        return "";
    if ((flags & Event.SHIFT_MASK) != 0)
        s += "Shift ";
    if ((flags & Event.CTRL_MASK) != 0)
        s += "Control ";
    if ((flags & Event.META_MASK) != 0)
        s += "Meta ";
    if ((flags & Event.ALT_MASK) != 0)
        s += "Alt ";
    s += "] ";/*www  .j  a  va2 s.  co  m*/
    return s;
}

From source file:com.t3.client.AppActions.java

private static int getMenuShortcutKeyMask() {
    int key = Toolkit.getDefaultToolkit().getMenuShortcutKeyMask();
    String prop = System.getProperty("os.name", "unknown");
    if ("darwin".equalsIgnoreCase(prop)) {
        // TODO Should we install our own AWTKeyStroke class?  If we do it should only be if menu shortcut is CTRL...
        if (key == Event.CTRL_MASK)
            key = Event.META_MASK;
        /*//from  w  ww  .j  av  a2 s  . com
         * In order for OpenJDK to work on Mac OS X, the user must have the
         * X11 package installed unless they're running headless. However,
         * in order for the Command key to work, the X11 Preferences must be
         * set to "Enable the Meta Key" in X11 applications. Essentially, if
         * this option is turned on, the Command key (called Meta in X11)
         * will be intercepted by the X11 package and not sent to the
         * application. The next step for TabletopTool will be better integration
         * with the Mac desktop to eliminate the X11 menu altogether.
         */
    }
    return key;
}

From source file:net.rptools.maptool.client.AppActions.java

private static int getMenuShortcutKeyMask() {
    int key = Toolkit.getDefaultToolkit().getMenuShortcutKeyMask();
    String prop = System.getProperty("os.name", "unknown");
    if ("darwin".equalsIgnoreCase(prop)) {
        // TODO Should we install our own AWTKeyStroke class?  If we do it should only be if menu shortcut is CTRL...
        if (key == Event.CTRL_MASK)
            key = Event.META_MASK;
        /*/*  w ww  .  j  a  v  a 2 s .  co m*/
         * In order for OpenJDK to work on Mac OS X, the user must have the
         * X11 package installed unless they're running headless. However,
         * in order for the Command key to work, the X11 Preferences must be
         * set to "Enable the Meta Key" in X11 applications. Essentially, if
         * this option is turned on, the Command key (called Meta in X11)
         * will be intercepted by the X11 package and not sent to the
         * application. The next step for MapTool will be better integration
         * with the Mac desktop to eliminate the X11 menu altogether.
         */
    }
    return key;
}

From source file:org.eclipse.jubula.rc.swing.driver.RobotAwtImpl.java

/**
 * {@inheritDoc}//from w  w  w .  ja v a2 s.  co  m
 */
public String getSystemModifierSpec() {
    String keyStrokeSpec = CompSystemConstants.MODIFIER_CONTROL;
    if (!(UIManager.getLookAndFeel().getID().equals(METAL_LAF_ID))) {
        if (Toolkit.getDefaultToolkit().getMenuShortcutKeyMask() == Event.META_MASK) {
            keyStrokeSpec = CompSystemConstants.MODIFIER_META;
        } else if (Toolkit.getDefaultToolkit().getMenuShortcutKeyMask() == Event.ALT_MASK) {
            keyStrokeSpec = CompSystemConstants.MODIFIER_ALT;
        }
    }
    return keyStrokeSpec;
}