Java Code Examples for java.awt.event.MouseEvent#getModifiersEx()

The following examples show how to use java.awt.event.MouseEvent#getModifiersEx() . 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: XMouseDragGestureRecognizer.java    From openjdk-jdk8u-backup with GNU General Public License v2.0 6 votes vote down vote up
/**
 * 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 2
Source File: XToolkit.java    From openjdk-jdk8u with GNU General Public License v2.0 6 votes vote down vote up
static boolean isRightMouseButton(MouseEvent me) {
    int numButtons = ((Integer)getDefaultToolkit().getDesktopProperty("awt.mouse.numButtons")).intValue();
    switch (me.getID()) {
      case MouseEvent.MOUSE_PRESSED:
      case MouseEvent.MOUSE_RELEASED:
          return ((numButtons == 2 && me.getButton() == MouseEvent.BUTTON2) ||
                   (numButtons > 2 && me.getButton() == MouseEvent.BUTTON3));
      case MouseEvent.MOUSE_ENTERED:
      case MouseEvent.MOUSE_EXITED:
      case MouseEvent.MOUSE_CLICKED:
      case MouseEvent.MOUSE_DRAGGED:
          return ((numButtons == 2 && (me.getModifiersEx() & InputEvent.BUTTON2_DOWN_MASK) != 0) ||
                  (numButtons > 2 && (me.getModifiersEx() & InputEvent.BUTTON3_DOWN_MASK) != 0));
    }
    return false;
}
 
Example 3
Source File: XMouseDragGestureRecognizer.java    From hottub with GNU General Public License v2.0 6 votes vote down vote up
/**
 * 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 4
Source File: XMouseDragGestureRecognizer.java    From jdk8u_jdk with GNU General Public License v2.0 6 votes vote down vote up
/**
 * 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: WMouseDragGestureRecognizer.java    From jdk8u_jdk with GNU General Public License v2.0 6 votes vote down vote up
/**
 * 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 6
Source File: XToolkit.java    From openjdk-jdk9 with GNU General Public License v2.0 6 votes vote down vote up
static boolean isRightMouseButton(MouseEvent me) {
    int numButtons = ((Integer)getDefaultToolkit().getDesktopProperty("awt.mouse.numButtons")).intValue();
    switch (me.getID()) {
      case MouseEvent.MOUSE_PRESSED:
      case MouseEvent.MOUSE_RELEASED:
          return ((numButtons == 2 && me.getButton() == MouseEvent.BUTTON2) ||
                   (numButtons > 2 && me.getButton() == MouseEvent.BUTTON3));
      case MouseEvent.MOUSE_ENTERED:
      case MouseEvent.MOUSE_EXITED:
      case MouseEvent.MOUSE_CLICKED:
      case MouseEvent.MOUSE_DRAGGED:
          return ((numButtons == 2 && (me.getModifiersEx() & InputEvent.BUTTON2_DOWN_MASK) != 0) ||
                  (numButtons > 2 && (me.getModifiersEx() & InputEvent.BUTTON3_DOWN_MASK) != 0));
    }
    return false;
}
 
Example 7
Source File: WMouseDragGestureRecognizer.java    From jdk8u-jdk with GNU General Public License v2.0 6 votes vote down vote up
/**
 * 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 8
Source File: CanvasMouseMotionListener.java    From freecol with GNU General Public License v2.0 5 votes vote down vote up
/**
 * {@inheritDoc}
 */
@Override
public void mouseDragged(MouseEvent me) {
    // getButton does not work here, TODO: find out why
    if ((me.getModifiersEx() & MouseEvent.BUTTON1_DOWN_MASK)
        != MouseEvent.BUTTON1_DOWN_MASK) return;
    performDragScrollIfActive(me);

    getGUI().updateGoto(me.getX(), me.getY(), true);
}
 
Example 9
Source File: XToolkit.java    From jdk8u_jdk with GNU General Public License v2.0 5 votes vote down vote up
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 10
Source File: XToolkit.java    From jdk8u-dev-jdk with GNU General Public License v2.0 5 votes vote down vote up
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 11
Source File: DefaultMapController.java    From amodeus with GNU General Public License v2.0 5 votes vote down vote up
@Override
public void mouseDragged(MouseEvent e) {
    if (!movementEnabled || !isMoving)
        return;
    // Is only the selected mouse button pressed?
    if ((e.getModifiersEx() & MOUSE_BUTTONS_MASK) == movementMouseButtonMask || (isPlatformOsx() && e.getModifiersEx() == MAC_MOUSE_BUTTON3_MASK)) {
        Point p = e.getPoint();
        if (lastDragPoint != null) {
            int diffx = lastDragPoint.x - p.x;
            int diffy = lastDragPoint.y - p.y;
            map.moveMap(diffx, diffy);
        }
        lastDragPoint = p;
    }
}
 
Example 12
Source File: SectorSelector.java    From hortonmachine with GNU General Public License v3.0 5 votes vote down vote up
public void mouseDragged(MouseEvent mouseEvent) {
    if (MouseEvent.BUTTON1_DOWN_MASK != mouseEvent.getModifiersEx())
        return;

    if (this.getShape().isResizeable())
        mouseEvent.consume(); // prevent view operations
}
 
Example 13
Source File: bug7170657.java    From jdk8u_jdk with GNU General Public License v2.0 5 votes vote down vote up
private static void test(final Frame frame, final MouseEvent me) {
    MouseEvent newme = SwingUtilities.convertMouseEvent(frame, me, frame);
    if (me.getModifiersEx() != newme.getModifiersEx()
            || me.getModifiers() != newme.getModifiers()) {
        fail(me, newme);
    }
}
 
Example 14
Source File: XToolkit.java    From TencentKona-8 with GNU General Public License v2.0 5 votes vote down vote up
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: LineMarkedEditorPane.java    From jpexs-decompiler with GNU General Public License v3.0 5 votes vote down vote up
@Override
public void mouseMoved(MouseEvent e) {

    ctrlDown = (e.getModifiersEx() & InputEvent.CTRL_DOWN_MASK) != 0;
    lastPos = e.getPoint();
    update();

}
 
Example 16
Source File: bug7170657.java    From TencentKona-8 with GNU General Public License v2.0 5 votes vote down vote up
private static void test(final Frame frame, final MouseEvent me) {
    MouseEvent newme = SwingUtilities.convertMouseEvent(frame, me, frame);
    if (me.getModifiersEx() != newme.getModifiersEx()
            || me.getModifiers() != newme.getModifiers()) {
        fail(me, newme);
    }
}
 
Example 17
Source File: bug7170657.java    From openjdk-jdk8u with GNU General Public License v2.0 5 votes vote down vote up
private static void test(final Frame frame, final MouseEvent me) {
    MouseEvent newme = SwingUtilities.convertMouseEvent(frame, me, frame);
    if (me.getModifiersEx() != newme.getModifiersEx()
            || me.getModifiers() != newme.getModifiers()) {
        fail(me, newme);
    }
}
 
Example 18
Source File: bug7170657.java    From openjdk-8 with GNU General Public License v2.0 5 votes vote down vote up
private static void test(final Frame frame, final MouseEvent me) {
    MouseEvent newme = SwingUtilities.convertMouseEvent(frame, me, frame);
    if (me.getModifiersEx() != newme.getModifiersEx()
            || me.getModifiers() != newme.getModifiers()) {
        fail(me, newme);
    }
}
 
Example 19
Source File: GlassPane.java    From netbeans with Apache License 2.0 4 votes vote down vote up
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 20
Source File: CanvasListener.java    From Logisim with GNU General Public License v3.0 4 votes vote down vote up
private boolean isButton1(MouseEvent e) {
	return (e.getModifiersEx() & InputEvent.BUTTON1_DOWN_MASK) != 0;
}