Java Code Examples for java.awt.event.InputEvent#META_DOWN_MASK
The following examples show how to use
java.awt.event.InputEvent#META_DOWN_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: InputEventUtil.java From Logisim with GNU General Public License v3.0 | 6 votes |
public static String toKeyDisplayString(int mods) { ArrayList<String> arr = new ArrayList<String>(); if ((mods & InputEvent.META_DOWN_MASK) != 0) arr.add(Strings.get("metaMod")); if ((mods & InputEvent.CTRL_DOWN_MASK) != 0) arr.add(Strings.get("ctrlMod")); if ((mods & InputEvent.ALT_DOWN_MASK) != 0) arr.add(Strings.get("altMod")); if ((mods & InputEvent.SHIFT_DOWN_MASK) != 0) arr.add(Strings.get("shiftMod")); Iterator<String> it = arr.iterator(); if (it.hasNext()) { StringBuilder ret = new StringBuilder(); ret.append(it.next()); while (it.hasNext()) { ret.append(" "); ret.append(it.next()); } return ret.toString(); } else { return ""; } }
Example 2
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 3
Source File: AWTKeyStroke.java From openjdk-8 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 4
Source File: bug7170657.java From hottub with GNU General Public License v2.0 | 6 votes |
public static void main(final String[] args) { final int mask = InputEvent.META_DOWN_MASK | InputEvent.CTRL_MASK; Frame f = new Frame(); MouseEvent mwe = new MouseWheelEvent(f, 1, 1, mask, 1, 1, 1, 1, 1, true, 1, 1, 1); MouseEvent mdme = new MenuDragMouseEvent(f, 1, 1, mask, 1, 1, 1, 1, 1, true, null, null); MouseEvent me = new MouseEvent(f, 1, 1, mask, 1, 1, 1, 1, 1, true, MouseEvent.NOBUTTON); test(f, mwe); test(f, mdme); test(f, me); if (FAILED) { throw new RuntimeException("Wrong mouse event"); } }
Example 5
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 6
Source File: AWTKeyStroke.java From hottub 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 7
Source File: AWTKeyStroke.java From openjdk-8-source with GNU General Public License v2.0 | 5 votes |
static String getModifiersText(int modifiers) { StringBuilder buf = new StringBuilder(); if ((modifiers & InputEvent.SHIFT_DOWN_MASK) != 0 ) { buf.append("shift "); } if ((modifiers & InputEvent.CTRL_DOWN_MASK) != 0 ) { buf.append("ctrl "); } if ((modifiers & InputEvent.META_DOWN_MASK) != 0 ) { buf.append("meta "); } if ((modifiers & InputEvent.ALT_DOWN_MASK) != 0 ) { buf.append("alt "); } if ((modifiers & InputEvent.ALT_GRAPH_DOWN_MASK) != 0 ) { buf.append("altGraph "); } if ((modifiers & InputEvent.BUTTON1_DOWN_MASK) != 0 ) { buf.append("button1 "); } if ((modifiers & InputEvent.BUTTON2_DOWN_MASK) != 0 ) { buf.append("button2 "); } if ((modifiers & InputEvent.BUTTON3_DOWN_MASK) != 0 ) { buf.append("button3 "); } return buf.toString(); }
Example 8
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 9
Source File: AWTKeyStroke.java From jdk8u60 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 Bytecoder with Apache License 2.0 | 5 votes |
@SuppressWarnings("deprecation") 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: InputDefaultsInitTask.java From darklaf with MIT License | 5 votes |
private void installCutCopyPasteShortcuts(final InputMap inputMap, final boolean useSimpleActionKeys) { final String copyActionKey = useSimpleActionKeys ? "copy" : DefaultEditorKit.copyAction; final String pasteActionKey = useSimpleActionKeys ? "paste" : DefaultEditorKit.pasteAction; final String cutActionKey = useSimpleActionKeys ? "cut" : DefaultEditorKit.cutAction; final int mask = SystemInfo.isMac ? InputEvent.META_DOWN_MASK : InputEvent.CTRL_DOWN_MASK; // Ctrl+Ins, Shift+Ins, Shift+Del inputMap.put(KeyStroke.getKeyStroke(KeyEvent.VK_INSERT, InputEvent.CTRL_DOWN_MASK), copyActionKey); inputMap.put(KeyStroke.getKeyStroke(KeyEvent.VK_INSERT, InputEvent.SHIFT_DOWN_MASK), pasteActionKey); inputMap.put(KeyStroke.getKeyStroke(KeyEvent.VK_DELETE, InputEvent.SHIFT_DOWN_MASK), cutActionKey); // Ctrl+C, Ctrl+V, Ctrl+X inputMap.put(KeyStroke.getKeyStroke(KeyEvent.VK_C, mask), copyActionKey); inputMap.put(KeyStroke.getKeyStroke(KeyEvent.VK_V, mask), pasteActionKey); inputMap.put(KeyStroke.getKeyStroke(KeyEvent.VK_X, mask), DefaultEditorKit.cutAction); }
Example 12
Source File: AWTKeyStroke.java From TencentKona-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: DeviceTest.java From marathonv5 with Apache License 2.0 | 5 votes |
protected String getModifiersExText(int modifiers) { StringBuffer buf = new StringBuffer(); if ((modifiers & InputEvent.META_DOWN_MASK) != 0) { buf.append("Meta"); buf.append("+"); } if ((modifiers & InputEvent.CTRL_DOWN_MASK) != 0) { buf.append("Ctrl"); buf.append("+"); } if ((modifiers & InputEvent.ALT_DOWN_MASK) != 0) { buf.append("Alt"); buf.append("+"); } if ((modifiers & InputEvent.SHIFT_DOWN_MASK) != 0) { buf.append("Shift"); buf.append("+"); } if ((modifiers & InputEvent.ALT_GRAPH_DOWN_MASK) != 0) { buf.append("Alt Graph"); buf.append("+"); } if ((modifiers & InputEvent.BUTTON1_DOWN_MASK) != 0) { buf.append("Button1"); buf.append("+"); } if ((modifiers & InputEvent.BUTTON2_DOWN_MASK) != 0) { buf.append("Button2"); buf.append("+"); } if ((modifiers & InputEvent.BUTTON3_DOWN_MASK) != 0) { buf.append("Button3"); buf.append("+"); } return buf.toString(); }
Example 14
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(); }
Example 15
Source File: MacOSDefaultKeymap.java From consulo with Apache License 2.0 | 4 votes |
@JdkConstants.InputEventMask private static int mapModifiers(@JdkConstants.InputEventMask int modifiers) { boolean meta = false; if ((modifiers & InputEvent.META_MASK) != 0) { modifiers &= ~InputEvent.META_MASK; meta = true; } boolean metaDown = false; if ((modifiers & InputEvent.META_DOWN_MASK) != 0) { modifiers &= ~InputEvent.META_DOWN_MASK; metaDown = true; } boolean control = false; if ((modifiers & InputEvent.CTRL_MASK) != 0) { modifiers &= ~InputEvent.CTRL_MASK; control = true; } boolean controlDown = false; if ((modifiers & InputEvent.CTRL_DOWN_MASK) != 0) { modifiers &= ~InputEvent.CTRL_DOWN_MASK; controlDown = true; } if (meta) { modifiers |= InputEvent.CTRL_MASK; } if (metaDown) { modifiers |= InputEvent.CTRL_DOWN_MASK; } if (control) { modifiers |= InputEvent.META_MASK; } if (controlDown) { modifiers |= InputEvent.META_DOWN_MASK; } return modifiers; }
Example 16
Source File: EditorCaret.java From netbeans with Apache License 2.0 | 4 votes |
private boolean isMiddleMouseButtonExt(MouseEvent evt) { return (evt.getButton() == MouseEvent.BUTTON2) && (evt.getModifiersEx() & (InputEvent.CTRL_DOWN_MASK | InputEvent.META_DOWN_MASK | /* cannot be tested bcs of bug in JDK InputEvent.ALT_DOWN_MASK | */ InputEvent.ALT_GRAPH_DOWN_MASK)) == 0; }
Example 17
Source File: CloseWindowAction.java From PIPE with MIT License | 4 votes |
/** * Constructor * @param applicationController PIPE main application controller */ public CloseWindowAction(PipeApplicationController applicationController) { super("Close", "Close the current tab", KeyEvent.VK_W, InputEvent.META_DOWN_MASK); this.applicationController = applicationController; }
Example 18
Source File: ChangesViewManager.java From consulo with Apache License 2.0 | 4 votes |
@JdkConstants.InputEventMask private static int ctrlMask() { return SystemInfo.isMac ? InputEvent.META_DOWN_MASK : InputEvent.CTRL_DOWN_MASK; }
Example 19
Source File: BaseCaret.java From netbeans with Apache License 2.0 | 4 votes |
private boolean isMiddleMouseButtonExt(MouseEvent evt) { return (evt.getButton() == MouseEvent.BUTTON2) && (evt.getModifiersEx() & (InputEvent.CTRL_DOWN_MASK | InputEvent.META_DOWN_MASK | /* cannot be tested bcs of bug in JDK InputEvent.ALT_DOWN_MASK | */ InputEvent.ALT_GRAPH_DOWN_MASK)) == 0; }
Example 20
Source File: HyperlinkOperation.java From netbeans with Apache License 2.0 | 4 votes |
private void readSettings() { String hyperlinkActivationKeyPropertyValue = System.getProperty("org.netbeans.lib.editor.hyperlink.HyperlinkOperation.activationKey"); if (hyperlinkActivationKeyPropertyValue != null) { if ("off".equals(hyperlinkActivationKeyPropertyValue)) { // NOI18N this.hyperlinkEnabled = false; this.actionKeyMask = (-1); } else { this.hyperlinkEnabled = true; this.actionKeyMask = (-1); for (int cntr = 0; cntr < hyperlinkActivationKeyPropertyValue.length(); cntr++) { int localMask = 0; switch (hyperlinkActivationKeyPropertyValue.charAt(cntr)) { case 'S': localMask = InputEvent.SHIFT_DOWN_MASK; break; case 'C': localMask = InputEvent.CTRL_DOWN_MASK; break; case 'A': localMask = InputEvent.ALT_DOWN_MASK; break; case 'M': localMask = InputEvent.META_DOWN_MASK; break; default: LOG.warning("Incorrect value of org.netbeans.lib.editor.hyperlink.HyperlinkOperation.activationKey property (only letters CSAM are allowed): " + hyperlinkActivationKeyPropertyValue.charAt(cntr)); } if (localMask == 0) { //some problem, ignore this.actionKeyMask = (-1); break; } if (this.actionKeyMask == (-1)) this.actionKeyMask = localMask; else this.actionKeyMask |= localMask; } if (this.actionKeyMask == (-1)) { LOG.warning("Some problem with property org.netbeans.lib.editor.hyperlink.HyperlinkOperation.activationKey, more information might be given above. Falling back to the default behaviour."); } else { return; } } } this.hyperlinkEnabled = true; Preferences prefs = MimeLookup.getLookup(DocumentUtilities.getMimeType(component)).lookup(Preferences.class); // there is in Mac preferences shortcut for META_MASK, by default we use CTRL_DOWN_MASK this.actionKeyMask = prefs.getInt(SimpleValueNames.HYPERLINK_ACTIVATION_MODIFIERS, InputEvent.CTRL_DOWN_MASK); // there is in Mac preferences shortcut for "META_DONW_MASK | InputEvent.ALT_DOWN_MASK", by default we use Ctrl+Alt this.altActionKeyMask = prefs.getInt(SimpleValueNames.ALT_HYPERLINK_ACTIVATION_MODIFIERS, InputEvent.CTRL_DOWN_MASK | InputEvent.ALT_DOWN_MASK); }