Java Code Examples for java.awt.event.InputEvent#BUTTON1_DOWN_MASK
The following examples show how to use
java.awt.event.InputEvent#BUTTON1_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: DragSourceDragEvent.java From jdk8u-jdk with GNU General Public License v2.0 | 6 votes |
/** * Sets old modifiers by the new ones. */ private void setOldModifiers() { if ((gestureModifiers & InputEvent.BUTTON1_DOWN_MASK) != 0) { gestureModifiers |= InputEvent.BUTTON1_MASK; } if ((gestureModifiers & InputEvent.BUTTON2_DOWN_MASK) != 0) { gestureModifiers |= InputEvent.BUTTON2_MASK; } if ((gestureModifiers & InputEvent.BUTTON3_DOWN_MASK) != 0) { gestureModifiers |= InputEvent.BUTTON3_MASK; } if ((gestureModifiers & InputEvent.SHIFT_DOWN_MASK) != 0) { gestureModifiers |= InputEvent.SHIFT_MASK; } if ((gestureModifiers & InputEvent.CTRL_DOWN_MASK) != 0) { gestureModifiers |= InputEvent.CTRL_MASK; } if ((gestureModifiers & InputEvent.ALT_GRAPH_DOWN_MASK) != 0) { gestureModifiers |= InputEvent.ALT_GRAPH_MASK; } }
Example 2
Source File: DragSourceDragEvent.java From openjdk-8 with GNU General Public License v2.0 | 6 votes |
/** * Sets old modifiers by the new ones. */ private void setOldModifiers() { if ((gestureModifiers & InputEvent.BUTTON1_DOWN_MASK) != 0) { gestureModifiers |= InputEvent.BUTTON1_MASK; } if ((gestureModifiers & InputEvent.BUTTON2_DOWN_MASK) != 0) { gestureModifiers |= InputEvent.BUTTON2_MASK; } if ((gestureModifiers & InputEvent.BUTTON3_DOWN_MASK) != 0) { gestureModifiers |= InputEvent.BUTTON3_MASK; } if ((gestureModifiers & InputEvent.SHIFT_DOWN_MASK) != 0) { gestureModifiers |= InputEvent.SHIFT_MASK; } if ((gestureModifiers & InputEvent.CTRL_DOWN_MASK) != 0) { gestureModifiers |= InputEvent.CTRL_MASK; } if ((gestureModifiers & InputEvent.ALT_GRAPH_DOWN_MASK) != 0) { gestureModifiers |= InputEvent.ALT_GRAPH_MASK; } }
Example 3
Source File: InputEventUtil.java From Logisim with GNU General Public License v3.0 | 6 votes |
public static int fromDisplayString(String str) { int ret = 0; StringTokenizer toks = new StringTokenizer(str); while (toks.hasMoreTokens()) { String s = toks.nextToken(); if (s.equals(Strings.get("ctrlMod"))) ret |= InputEvent.CTRL_DOWN_MASK; else if (s.equals(Strings.get("altMod"))) ret |= InputEvent.ALT_DOWN_MASK; else if (s.equals(Strings.get("shiftMod"))) ret |= InputEvent.SHIFT_DOWN_MASK; else if (s.equals(Strings.get("button1Mod"))) ret |= InputEvent.BUTTON1_DOWN_MASK; else if (s.equals(Strings.get("button2Mod"))) ret |= InputEvent.BUTTON2_DOWN_MASK; else if (s.equals(Strings.get("button3Mod"))) ret |= InputEvent.BUTTON3_DOWN_MASK; else throw new NumberFormatException("InputEventUtil"); } return ret; }
Example 4
Source File: XMouseDragGestureRecognizer.java From openjdk-jdk8u with GNU General Public License v2.0 | 6 votes |
/** * determine the drop action from the event */ protected int mapDragOperationFromModifiers(MouseEvent e) { int mods = e.getModifiersEx(); int btns = mods & ButtonMask; // Do not allow right mouse button drag since Motif DnD does not // terminate drag operation on right mouse button release. if (!(btns == InputEvent.BUTTON1_DOWN_MASK || btns == InputEvent.BUTTON2_DOWN_MASK)) { return DnDConstants.ACTION_NONE; } return SunDragSourceContextPeer.convertModifiersToDropAction(mods, getSourceActions()); }
Example 5
Source File: Robot.java From jdk8u60 with GNU General Public License v2.0 | 6 votes |
private static synchronized void initLegalButtonMask() { if (LEGAL_BUTTON_MASK != 0) return; int tmpMask = 0; if (Toolkit.getDefaultToolkit().areExtraMouseButtonsEnabled()){ if (Toolkit.getDefaultToolkit() instanceof SunToolkit) { final int buttonsNumber = ((SunToolkit)(Toolkit.getDefaultToolkit())).getNumberOfButtons(); for (int i = 0; i < buttonsNumber; i++){ tmpMask |= InputEvent.getMaskForButton(i+1); } } } tmpMask |= InputEvent.BUTTON1_MASK| InputEvent.BUTTON2_MASK| InputEvent.BUTTON3_MASK| InputEvent.BUTTON1_DOWN_MASK| InputEvent.BUTTON2_DOWN_MASK| InputEvent.BUTTON3_DOWN_MASK; LEGAL_BUTTON_MASK = tmpMask; }
Example 6
Source File: Robot.java From jdk-1.7-annotated with Apache License 2.0 | 6 votes |
private static synchronized void initLegalButtonMask() { if (LEGAL_BUTTON_MASK != 0) return; int tmpMask = 0; if (Toolkit.getDefaultToolkit().areExtraMouseButtonsEnabled()){ if (Toolkit.getDefaultToolkit() instanceof SunToolkit) { final int buttonsNumber = ((SunToolkit)(Toolkit.getDefaultToolkit())).getNumberOfButtons(); for (int i = 0; i < buttonsNumber; i++){ tmpMask |= InputEvent.getMaskForButton(i+1); } } } tmpMask |= InputEvent.BUTTON1_MASK| InputEvent.BUTTON2_MASK| InputEvent.BUTTON3_MASK| InputEvent.BUTTON1_DOWN_MASK| InputEvent.BUTTON2_DOWN_MASK| InputEvent.BUTTON3_DOWN_MASK; LEGAL_BUTTON_MASK = tmpMask; }
Example 7
Source File: DragSourceDragEvent.java From Java8CN with Apache License 2.0 | 6 votes |
/** * Sets old modifiers by the new ones. */ private void setOldModifiers() { if ((gestureModifiers & InputEvent.BUTTON1_DOWN_MASK) != 0) { gestureModifiers |= InputEvent.BUTTON1_MASK; } if ((gestureModifiers & InputEvent.BUTTON2_DOWN_MASK) != 0) { gestureModifiers |= InputEvent.BUTTON2_MASK; } if ((gestureModifiers & InputEvent.BUTTON3_DOWN_MASK) != 0) { gestureModifiers |= InputEvent.BUTTON3_MASK; } if ((gestureModifiers & InputEvent.SHIFT_DOWN_MASK) != 0) { gestureModifiers |= InputEvent.SHIFT_MASK; } if ((gestureModifiers & InputEvent.CTRL_DOWN_MASK) != 0) { gestureModifiers |= InputEvent.CTRL_MASK; } if ((gestureModifiers & InputEvent.ALT_GRAPH_DOWN_MASK) != 0) { gestureModifiers |= InputEvent.ALT_GRAPH_MASK; } }
Example 8
Source File: WMouseDragGestureRecognizer.java From jdk8u-dev-jdk with GNU General Public License v2.0 | 6 votes |
/** * determine the drop action from the event */ protected int mapDragOperationFromModifiers(MouseEvent e) { int mods = e.getModifiersEx(); int btns = mods & ButtonMask; // Prohibit multi-button drags. if (!(btns == InputEvent.BUTTON1_DOWN_MASK || btns == InputEvent.BUTTON2_DOWN_MASK || btns == InputEvent.BUTTON3_DOWN_MASK)) { return DnDConstants.ACTION_NONE; } return SunDragSourceContextPeer.convertModifiersToDropAction(mods, getSourceActions()); }
Example 9
Source File: AWTKeyStroke.java From jdk1.8-source-analysis with Apache License 2.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: OSUtils.java From marathonv5 with Apache License 2.0 | 5 votes |
public static String inputEventGetModifiersExText(int modifiers) { StringBuffer sb = new StringBuffer(); if ((modifiers & InputEvent.CTRL_DOWN_MASK) != 0) { sb.append("Ctrl+"); } if ((modifiers & InputEvent.META_DOWN_MASK) != 0) { sb.append("Meta+"); } if ((modifiers & InputEvent.ALT_DOWN_MASK) != 0) { sb.append("Alt+"); } if ((modifiers & InputEvent.SHIFT_DOWN_MASK) != 0) { sb.append("Shift+"); } if ((modifiers & InputEvent.BUTTON1_DOWN_MASK) != 0) { sb.append("Button1+"); } if ((modifiers & InputEvent.BUTTON2_DOWN_MASK) != 0) { sb.append("Button2+"); } if ((modifiers & InputEvent.BUTTON3_DOWN_MASK) != 0) { sb.append("Button3+"); } String text = sb.toString(); if (text.equals("")) { return text; } return text.substring(0, text.length() - 1); }
Example 11
Source File: AWTKeyStroke.java From Java8CN with Apache License 2.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: Robot.java From karate with MIT License | 5 votes |
private static int mask(int num) { switch (num) { case 2: return InputEvent.BUTTON2_DOWN_MASK; case 3: return InputEvent.BUTTON3_DOWN_MASK; default: return InputEvent.BUTTON1_DOWN_MASK; } }
Example 13
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 14
Source File: XToolkit.java From hottub with GNU General Public License v2.0 | 5 votes |
static boolean isLeftMouseButton(MouseEvent me) { switch (me.getID()) { case MouseEvent.MOUSE_PRESSED: case MouseEvent.MOUSE_RELEASED: return (me.getButton() == MouseEvent.BUTTON1); case MouseEvent.MOUSE_ENTERED: case MouseEvent.MOUSE_EXITED: case MouseEvent.MOUSE_CLICKED: case MouseEvent.MOUSE_DRAGGED: return ((me.getModifiersEx() & InputEvent.BUTTON1_DOWN_MASK) != 0); } return false; }
Example 15
Source File: AWTKeyStroke.java From Bytecoder with Apache License 2.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 16
Source File: AWTKeyStroke.java From jdk-1.7-annotated with Apache License 2.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 17
Source File: CanvasListener.java From Logisim with GNU General Public License v3.0 | 4 votes |
private boolean isButton1(MouseEvent e) { return (e.getModifiersEx() & InputEvent.BUTTON1_DOWN_MASK) != 0; }
Example 18
Source File: VncClientPacketSender.java From cloudstack with Apache License 2.0 | 3 votes |
/** * Current state of buttons 1 to 8 are represented by bits 0 to 7 of * button-mask respectively, 0 meaning up, 1 meaning down (pressed). On a * conventional mouse, buttons 1, 2 and 3 correspond to the left, middle and * right buttons on the mouse. On a wheel mouse, each step of the wheel * upwards is represented by a press and release of button 4, and each step * downwards is represented by a press and release of button 5. * * @param modifiers * extended modifiers from AWT mouse event * @return VNC mouse button mask */ public static int mapAwtModifiersToVncButtonMask(int modifiers) { int mask = (((modifiers & InputEvent.BUTTON1_DOWN_MASK) != 0) ? 0x1 : 0) | (((modifiers & InputEvent.BUTTON2_DOWN_MASK) != 0) ? 0x2 : 0) | (((modifiers & InputEvent.BUTTON3_DOWN_MASK) != 0) ? 0x4 : 0); return mask; }
Example 19
Source File: AwtVncMouseAdapter.java From cloudstack with Apache License 2.0 | 2 votes |
/** * Current state of buttons 1 to 8 are represented by bits 0 to 7 of * button-mask respectively, 0 meaning up, 1 meaning down (pressed). On a * conventional mouse, buttons 1, 2 and 3 correspond to the left, middle and * right buttons on the mouse. On a wheel mouse, each step of the wheel * upwards is represented by a press and release of button 4, and each step * downwards is represented by a press and release of button 5. * * @param modifiers * extended modifiers from AWT mouse event * @return VNC mouse button mask */ public static int mapAwtModifiersToVncButtonMask(int modifiers) { int mask = (((modifiers & InputEvent.BUTTON1_DOWN_MASK) != 0) ? 0x1 : 0) | (((modifiers & InputEvent.BUTTON2_DOWN_MASK) != 0) ? 0x2 : 0) | (((modifiers & InputEvent.BUTTON3_DOWN_MASK) != 0) ? 0x4 : 0); return mask; }
Example 20
Source File: JBSwingUtilities.java From consulo with Apache License 2.0 | 2 votes |
/** * Replaces SwingUtilities#isLeftMouseButton() for consistency with other button-related methods * * @see SwingUtilities#isLeftMouseButton(MouseEvent) */ public static boolean isLeftMouseButton(MouseEvent anEvent) { return LEGACY_JDK ? (anEvent.getModifiersEx() & InputEvent.BUTTON1_DOWN_MASK) > 0 : SwingUtilities.isLeftMouseButton(anEvent); }