Java Code Examples for java.awt.event.InputEvent#META_MASK
The following examples show how to use
java.awt.event.InputEvent#META_MASK .
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: AWTKeyStroke.java From jdk1.8-source-analysis with Apache License 2.0 | 6 votes |
private static int mapNewModifiers(int modifiers) { if ((modifiers & InputEvent.SHIFT_DOWN_MASK) != 0) { modifiers |= InputEvent.SHIFT_MASK; } if ((modifiers & InputEvent.ALT_DOWN_MASK) != 0) { modifiers |= InputEvent.ALT_MASK; } if ((modifiers & InputEvent.ALT_GRAPH_DOWN_MASK) != 0) { modifiers |= InputEvent.ALT_GRAPH_MASK; } if ((modifiers & InputEvent.CTRL_DOWN_MASK) != 0) { modifiers |= InputEvent.CTRL_MASK; } if ((modifiers & InputEvent.META_DOWN_MASK) != 0) { modifiers |= InputEvent.META_MASK; } return modifiers; }
Example 2
Source File: EventQueueDevice.java From marathonv5 with Apache License 2.0 | 6 votes |
public int getModifierEx() { int modifiersEx = 0; if (isShiftPressed()) { modifiersEx |= InputEvent.SHIFT_DOWN_MASK | InputEvent.SHIFT_MASK; } if (isCtrlPressed()) { modifiersEx |= InputEvent.CTRL_DOWN_MASK | InputEvent.CTRL_MASK; } if (isAltPressed()) { modifiersEx |= InputEvent.ALT_DOWN_MASK | InputEvent.ALT_MASK; } if (isMetaPressed()) { modifiersEx |= InputEvent.META_DOWN_MASK | InputEvent.META_MASK; } return modifiersEx; }
Example 3
Source File: ActivateToolWindowAction.java From consulo with Apache License 2.0 | 6 votes |
/** * @return mnemonic for action if it has Alt+digit/Meta+digit shortcut. * Otherwise the method returns <code>-1</code>. Meta mask is OK for * Mac OS X user, because Alt+digit types strange characters into the * editor. */ public static int getMnemonicForToolWindow(String id) { Keymap activeKeymap = KeymapManager.getInstance().getActiveKeymap(); Shortcut[] shortcuts = activeKeymap.getShortcuts(getActionIdForToolWindow(id)); for (Shortcut shortcut : shortcuts) { if (shortcut instanceof KeyboardShortcut) { KeyStroke keyStroke = ((KeyboardShortcut)shortcut).getFirstKeyStroke(); int modifiers = keyStroke.getModifiers(); if (modifiers == (InputEvent.ALT_DOWN_MASK | InputEvent.ALT_MASK) || modifiers == InputEvent.ALT_MASK || modifiers == InputEvent.ALT_DOWN_MASK || modifiers == (InputEvent.META_DOWN_MASK | InputEvent.META_MASK) || modifiers == InputEvent.META_MASK || modifiers == InputEvent.META_DOWN_MASK) { int keyCode = keyStroke.getKeyCode(); if (KeyEvent.VK_0 <= keyCode && keyCode <= KeyEvent.VK_9) { char c = (char)('0' + keyCode - KeyEvent.VK_0); return (int)c; } } } } return -1; }
Example 4
Source File: AWTKeyStroke.java From jdk8u-jdk with GNU General Public License v2.0 | 6 votes |
private static int mapNewModifiers(int modifiers) { if ((modifiers & InputEvent.SHIFT_DOWN_MASK) != 0) { modifiers |= InputEvent.SHIFT_MASK; } if ((modifiers & InputEvent.ALT_DOWN_MASK) != 0) { modifiers |= InputEvent.ALT_MASK; } if ((modifiers & InputEvent.ALT_GRAPH_DOWN_MASK) != 0) { modifiers |= InputEvent.ALT_GRAPH_MASK; } if ((modifiers & InputEvent.CTRL_DOWN_MASK) != 0) { modifiers |= InputEvent.CTRL_MASK; } if ((modifiers & InputEvent.META_DOWN_MASK) != 0) { modifiers |= InputEvent.META_MASK; } return modifiers; }
Example 5
Source File: AWTKeyStroke.java From JDKSourceCode1.8 with MIT License | 6 votes |
private static int mapNewModifiers(int modifiers) { if ((modifiers & InputEvent.SHIFT_DOWN_MASK) != 0) { modifiers |= InputEvent.SHIFT_MASK; } if ((modifiers & InputEvent.ALT_DOWN_MASK) != 0) { modifiers |= InputEvent.ALT_MASK; } if ((modifiers & InputEvent.ALT_GRAPH_DOWN_MASK) != 0) { modifiers |= InputEvent.ALT_GRAPH_MASK; } if ((modifiers & InputEvent.CTRL_DOWN_MASK) != 0) { modifiers |= InputEvent.CTRL_MASK; } if ((modifiers & InputEvent.META_DOWN_MASK) != 0) { modifiers |= InputEvent.META_MASK; } return modifiers; }
Example 6
Source File: AWTKeyStroke.java From openjdk-8-source with GNU General Public License v2.0 | 6 votes |
private static int mapNewModifiers(int modifiers) { if ((modifiers & InputEvent.SHIFT_DOWN_MASK) != 0) { modifiers |= InputEvent.SHIFT_MASK; } if ((modifiers & InputEvent.ALT_DOWN_MASK) != 0) { modifiers |= InputEvent.ALT_MASK; } if ((modifiers & InputEvent.ALT_GRAPH_DOWN_MASK) != 0) { modifiers |= InputEvent.ALT_GRAPH_MASK; } if ((modifiers & InputEvent.CTRL_DOWN_MASK) != 0) { modifiers |= InputEvent.CTRL_MASK; } if ((modifiers & InputEvent.META_DOWN_MASK) != 0) { modifiers |= InputEvent.META_MASK; } return modifiers; }
Example 7
Source File: AWTKeyStroke.java From Bytecoder with Apache License 2.0 | 6 votes |
@SuppressWarnings("deprecation") private static int mapNewModifiers(int modifiers) { if ((modifiers & InputEvent.SHIFT_DOWN_MASK) != 0) { modifiers |= InputEvent.SHIFT_MASK; } if ((modifiers & InputEvent.ALT_DOWN_MASK) != 0) { modifiers |= InputEvent.ALT_MASK; } if ((modifiers & InputEvent.ALT_GRAPH_DOWN_MASK) != 0) { modifiers |= InputEvent.ALT_GRAPH_MASK; } if ((modifiers & InputEvent.CTRL_DOWN_MASK) != 0) { modifiers |= InputEvent.CTRL_MASK; } if ((modifiers & InputEvent.META_DOWN_MASK) != 0) { modifiers |= InputEvent.META_MASK; } return modifiers; }
Example 8
Source File: AWTKeyStroke.java From hottub with GNU General Public License v2.0 | 6 votes |
private static int mapNewModifiers(int modifiers) { if ((modifiers & InputEvent.SHIFT_DOWN_MASK) != 0) { modifiers |= InputEvent.SHIFT_MASK; } if ((modifiers & InputEvent.ALT_DOWN_MASK) != 0) { modifiers |= InputEvent.ALT_MASK; } if ((modifiers & InputEvent.ALT_GRAPH_DOWN_MASK) != 0) { modifiers |= InputEvent.ALT_GRAPH_MASK; } if ((modifiers & InputEvent.CTRL_DOWN_MASK) != 0) { modifiers |= InputEvent.CTRL_MASK; } if ((modifiers & InputEvent.META_DOWN_MASK) != 0) { modifiers |= InputEvent.META_MASK; } return modifiers; }
Example 9
Source File: AWTKeyStroke.java From jdk8u-jdk with GNU General Public License v2.0 | 5 votes |
private static int mapOldModifiers(int modifiers) { if ((modifiers & InputEvent.SHIFT_MASK) != 0) { modifiers |= InputEvent.SHIFT_DOWN_MASK; } if ((modifiers & InputEvent.ALT_MASK) != 0) { modifiers |= InputEvent.ALT_DOWN_MASK; } if ((modifiers & InputEvent.ALT_GRAPH_MASK) != 0) { modifiers |= InputEvent.ALT_GRAPH_DOWN_MASK; } if ((modifiers & InputEvent.CTRL_MASK) != 0) { modifiers |= InputEvent.CTRL_DOWN_MASK; } if ((modifiers & InputEvent.META_MASK) != 0) { modifiers |= InputEvent.META_DOWN_MASK; } modifiers &= InputEvent.SHIFT_DOWN_MASK | InputEvent.ALT_DOWN_MASK | InputEvent.ALT_GRAPH_DOWN_MASK | InputEvent.CTRL_DOWN_MASK | InputEvent.META_DOWN_MASK | InputEvent.BUTTON1_DOWN_MASK | InputEvent.BUTTON2_DOWN_MASK | InputEvent.BUTTON3_DOWN_MASK; return modifiers; }
Example 10
Source File: AWTKeyStroke.java From JDKSourceCode1.8 with MIT License | 5 votes |
private static int mapOldModifiers(int modifiers) { if ((modifiers & InputEvent.SHIFT_MASK) != 0) { modifiers |= InputEvent.SHIFT_DOWN_MASK; } if ((modifiers & InputEvent.ALT_MASK) != 0) { modifiers |= InputEvent.ALT_DOWN_MASK; } if ((modifiers & InputEvent.ALT_GRAPH_MASK) != 0) { modifiers |= InputEvent.ALT_GRAPH_DOWN_MASK; } if ((modifiers & InputEvent.CTRL_MASK) != 0) { modifiers |= InputEvent.CTRL_DOWN_MASK; } if ((modifiers & InputEvent.META_MASK) != 0) { modifiers |= InputEvent.META_DOWN_MASK; } modifiers &= InputEvent.SHIFT_DOWN_MASK | InputEvent.ALT_DOWN_MASK | InputEvent.ALT_GRAPH_DOWN_MASK | InputEvent.CTRL_DOWN_MASK | InputEvent.META_DOWN_MASK | InputEvent.BUTTON1_DOWN_MASK | InputEvent.BUTTON2_DOWN_MASK | InputEvent.BUTTON3_DOWN_MASK; return modifiers; }
Example 11
Source File: AWTKeyStroke.java From openjdk-jdk8u-backup with GNU General Public License v2.0 | 5 votes |
private static int mapOldModifiers(int modifiers) { if ((modifiers & InputEvent.SHIFT_MASK) != 0) { modifiers |= InputEvent.SHIFT_DOWN_MASK; } if ((modifiers & InputEvent.ALT_MASK) != 0) { modifiers |= InputEvent.ALT_DOWN_MASK; } if ((modifiers & InputEvent.ALT_GRAPH_MASK) != 0) { modifiers |= InputEvent.ALT_GRAPH_DOWN_MASK; } if ((modifiers & InputEvent.CTRL_MASK) != 0) { modifiers |= InputEvent.CTRL_DOWN_MASK; } if ((modifiers & InputEvent.META_MASK) != 0) { modifiers |= InputEvent.META_DOWN_MASK; } modifiers &= InputEvent.SHIFT_DOWN_MASK | InputEvent.ALT_DOWN_MASK | InputEvent.ALT_GRAPH_DOWN_MASK | InputEvent.CTRL_DOWN_MASK | InputEvent.META_DOWN_MASK | InputEvent.BUTTON1_DOWN_MASK | InputEvent.BUTTON2_DOWN_MASK | InputEvent.BUTTON3_DOWN_MASK; return modifiers; }
Example 12
Source File: AWTKeyStroke.java From openjdk-8 with GNU General Public License v2.0 | 5 votes |
private static int mapOldModifiers(int modifiers) { if ((modifiers & InputEvent.SHIFT_MASK) != 0) { modifiers |= InputEvent.SHIFT_DOWN_MASK; } if ((modifiers & InputEvent.ALT_MASK) != 0) { modifiers |= InputEvent.ALT_DOWN_MASK; } if ((modifiers & InputEvent.ALT_GRAPH_MASK) != 0) { modifiers |= InputEvent.ALT_GRAPH_DOWN_MASK; } if ((modifiers & InputEvent.CTRL_MASK) != 0) { modifiers |= InputEvent.CTRL_DOWN_MASK; } if ((modifiers & InputEvent.META_MASK) != 0) { modifiers |= InputEvent.META_DOWN_MASK; } modifiers &= InputEvent.SHIFT_DOWN_MASK | InputEvent.ALT_DOWN_MASK | InputEvent.ALT_GRAPH_DOWN_MASK | InputEvent.CTRL_DOWN_MASK | InputEvent.META_DOWN_MASK | InputEvent.BUTTON1_DOWN_MASK | InputEvent.BUTTON2_DOWN_MASK | InputEvent.BUTTON3_DOWN_MASK; return modifiers; }
Example 13
Source File: CMenuItem.java From dragonwell8_jdk with GNU General Public License v2.0 | 5 votes |
public void setLabel(String label, char keyChar, int keyCode, int modifiers) { int keyMask = modifiers; if (keyCode == KeyEvent.VK_UNDEFINED) { MenuShortcut shortcut = ((MenuItem)getTarget()).getShortcut(); if (shortcut != null) { keyCode = shortcut.getKey(); keyMask |= InputEvent.META_MASK; if (shortcut.usesShiftModifier()) { keyMask |= InputEvent.SHIFT_MASK; } } } if (label == null) { label = ""; } // <rdar://problem/3654824> // Native code uses a keyChar of 0 to indicate that the // keyCode should be used to generate the shortcut. Translate // CHAR_UNDEFINED into 0. if (keyChar == KeyEvent.CHAR_UNDEFINED) { keyChar = 0; } final String finalLabel = label; final char finalKeyChar = keyChar; final int finalKeyCode = keyCode; final int finalKeyMask = keyMask; execute(ptr -> nativeSetLabel(ptr, finalLabel, finalKeyChar, finalKeyCode, finalKeyMask)); }
Example 14
Source File: RobotDriver.java From openjdk-jdk9 with GNU General Public License v2.0 | 5 votes |
/** * Releases modifiers keys by robot. * * @param modifiers a combination of {@code InputEvent.*_MASK} fields. */ protected void releaseModifiers(int modifiers) { if ((modifiers & InputEvent.SHIFT_MASK) != 0) { releaseKey(KeyEvent.VK_SHIFT, modifiers & ~InputEvent.SHIFT_MASK); } else if ((modifiers & InputEvent.ALT_GRAPH_MASK) != 0) { releaseKey(KeyEvent.VK_ALT_GRAPH, modifiers & ~InputEvent.ALT_GRAPH_MASK); } else if ((modifiers & InputEvent.ALT_MASK) != 0) { releaseKey(KeyEvent.VK_ALT, modifiers & ~InputEvent.ALT_MASK); } else if ((modifiers & InputEvent.META_MASK) != 0) { releaseKey(KeyEvent.VK_META, modifiers & ~InputEvent.META_MASK); } else if ((modifiers & InputEvent.CTRL_MASK) != 0) { releaseKey(KeyEvent.VK_CONTROL, modifiers & ~InputEvent.CTRL_MASK); } }
Example 15
Source File: GlassPane.java From netbeans with Apache License 2.0 | 4 votes |
private static boolean ctrlOrCmdModifier(MouseEvent e) { if (Toolkit.getDefaultToolkit().getMenuShortcutKeyMask() == InputEvent.META_MASK) { // on Mac return (e.getModifiersEx() & InputEvent.META_DOWN_MASK) == InputEvent.META_DOWN_MASK; } return (e.getModifiers() & InputEvent.CTRL_MASK) == InputEvent.CTRL_MASK; }
Example 16
Source File: LWCToolkit.java From jdk8u_jdk with GNU General Public License v2.0 | 4 votes |
/** * Tests whether specified key modifiers mask can be used to enter a * printable character. */ @Override public boolean isPrintableCharacterModifiersMask(int mods) { return ((mods & (InputEvent.META_MASK | InputEvent.CTRL_MASK)) == 0); }
Example 17
Source File: LWCToolkit.java From dragonwell8_jdk with GNU General Public License v2.0 | 4 votes |
/** * Tests whether specified key modifiers mask can be used to enter a * printable character. */ @Override public boolean isPrintableCharacterModifiersMask(int mods) { return ((mods & (InputEvent.META_MASK | InputEvent.CTRL_MASK)) == 0); }
Example 18
Source File: StructureFilterPopupComponent.java From consulo with Apache License 2.0 | 4 votes |
@JdkConstants.InputEventMask private int getMask() { return SystemInfo.isMac ? InputEvent.META_MASK : InputEvent.CTRL_MASK; }
Example 19
Source File: Utils.java From TrakEM2 with GNU General Public License v3.0 | 4 votes |
/** The CTRL key functionality is passed over to the COMMAND key (aka META key) in a MacOSX. */ static public final int getControlModifier() { return IJ.isMacOSX() ? InputEvent.META_MASK : InputEvent.CTRL_MASK; }
Example 20
Source File: StringUtils.java From xyTalk-pc with GNU Affero General Public License v3.0 | 4 votes |
public static String keyStroke2String(KeyStroke key) { StringBuilder s = new StringBuilder(50); int m = key.getModifiers(); if ((m & (InputEvent.SHIFT_DOWN_MASK | InputEvent.SHIFT_MASK)) != 0) { s.append("shift "); } if ((m & (InputEvent.CTRL_DOWN_MASK | InputEvent.CTRL_MASK)) != 0) { s.append("ctrl "); } if ((m & (InputEvent.META_DOWN_MASK | InputEvent.META_MASK)) != 0) { s.append("meta "); } if ((m & (InputEvent.ALT_DOWN_MASK | InputEvent.ALT_MASK)) != 0) { s.append("alt "); } if ((m & (InputEvent.BUTTON1_DOWN_MASK | InputEvent.BUTTON1_MASK)) != 0) { s.append("button1 "); } if ((m & (InputEvent.BUTTON2_DOWN_MASK | InputEvent.BUTTON2_MASK)) != 0) { s.append("button2 "); } if ((m & (InputEvent.BUTTON3_DOWN_MASK | InputEvent.BUTTON3_MASK)) != 0) { s.append("button3 "); } switch (key.getKeyEventType()) { case KeyEvent.KEY_TYPED: s.append("typed "); s.append(key.getKeyChar()).append(" "); break; case KeyEvent.KEY_PRESSED: s.append("pressed "); s.append(getKeyText(key.getKeyCode())).append(" "); break; case KeyEvent.KEY_RELEASED: s.append("released "); s.append(getKeyText(key.getKeyCode())).append(" "); break; default: s.append("unknown-event-type "); break; } return s.toString(); }