Java Code Examples for java.awt.event.MouseEvent#CTRL_DOWN_MASK

The following examples show how to use java.awt.event.MouseEvent#CTRL_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: DefaultMapController.java    From amodeus with GNU General Public License v2.0 6 votes vote down vote up
@Override
public void mouseMoved(MouseEvent e) {
    // Mac OSX simulates with ctrl + mouse 1 the second mouse button hence no dragging events get fired.
    //
    if (isPlatformOsx()) {
        if (!movementEnabled || !isMoving)
            return;
        // Is only the selected mouse button pressed?
        if (e.getModifiersEx() == MouseEvent.CTRL_DOWN_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 2
Source File: ContiguousSelectAction.java    From netbeans with Apache License 2.0 6 votes vote down vote up
private boolean process (Widget widget, Point localLocation, int modifiers) {
    boolean ctrl = (modifiers & MouseEvent.CTRL_DOWN_MASK) != 0;
    boolean shift = (modifiers & MouseEvent.SHIFT_DOWN_MASK) != 0;
    ContiguousSelectEvent.SelectionType type = ctrl
            ? (shift ? ContiguousSelectEvent.SelectionType.ADDITIVE_CONTIGUOUS : ContiguousSelectEvent.SelectionType.ADDITIVE_NON_CONTIGUOUS)
            : (shift ? ContiguousSelectEvent.SelectionType.REPLACE_CONTIGUOUS : ContiguousSelectEvent.SelectionType.REPLACE_NON_CONTIGUOUS);
    ContiguousSelectEvent providerEvent = ContiguousSelectEvent.create (previousWidget, previousLocalLocation, widget, localLocation, type);
    if (provider.isSelectionAllowed (providerEvent)) {
        provider.select(providerEvent);
        if (! shift) {
            previousWidget = widget;
            previousLocalLocation = localLocation;
        }
        return true;
    }
    return false;
}
 
Example 3
Source File: DefaultMapController.java    From Course_Generator with GNU General Public License v3.0 6 votes vote down vote up
public void mouseMoved(MouseEvent e) {
	// Mac OSX simulates with ctrl + mouse 1 the second mouse button hence no
	// dragging events get fired.
	//
	if (isPlatformOsx()) {
		if (!movementEnabled || !isMoving)
			return;
		// Is only the selected mouse button pressed?
		if (e.getModifiersEx() == MouseEvent.CTRL_DOWN_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 4
Source File: MainFrame.java    From zxpoly with GNU General Public License v3.0 6 votes vote down vote up
private int extractButtons(final MouseEvent event) {
  int result = AbstractTool.BUTTON_NONE;
  if ((event.getModifiersEx() & MouseEvent.CTRL_DOWN_MASK) != 0) {
    result |= AbstractTool.BUTTON_CTRL;
  }
  if ((event.getModifiersEx() & MouseEvent.ALT_DOWN_MASK) != 0) {
    result |= AbstractTool.BUTTON_ALT;
  }
  if ((event.getModifiersEx() & MouseEvent.SHIFT_DOWN_MASK) != 0) {
    result |= AbstractTool.BUTTON_SHIFT;
  }
  if ((event.getModifiersEx() & MouseEvent.BUTTON1_DOWN_MASK) != 0) {
    result |= AbstractTool.BUTTON_MOUSE_LEFT;
  }
  if ((event.getModifiersEx() & MouseEvent.BUTTON2_DOWN_MASK) != 0) {
    result |= AbstractTool.BUTTON_MOUSE_MIDDLE;
  }
  if ((event.getModifiersEx() & MouseEvent.BUTTON3_DOWN_MASK) != 0) {
    result |= AbstractTool.BUTTON_MOUSE_RIGHT;
  }
  return result;
}
 
Example 5
Source File: SelectAction.java    From netbeans with Apache License 2.0 5 votes vote down vote up
public State mousePressed (Widget widget, WidgetMouseEvent event) {
    if (isLocked()) {
        return State.createLocked(widget, this);
    }
    
    Point localLocation = event.getPoint();
    
    if (event.getButton() == MouseEvent.BUTTON1 || event.getButton() == MouseEvent.BUTTON2) {
        invertSelection = (event.getModifiersEx() & MouseEvent.CTRL_DOWN_MASK) != 0;
        
        if (provider.isSelectionAllowed(widget, localLocation, invertSelection)) {
            aiming = provider.isAimingAllowed(widget, localLocation, invertSelection);
            if (aiming) {
                updateState(widget, localLocation);
                return State.createLocked(widget, this);
            } else {
                provider.select(widget, localLocation, invertSelection);
                return State.CHAIN_ONLY;
            }
        }
    } else if (trapRightClick && event.getButton() == MouseEvent.BUTTON3) {
        provider.select(widget, localLocation, false);
        return State.CHAIN_ONLY;
    }
    
    return State.REJECTED;
}
 
Example 6
Source File: WatchAnnotationProvider.java    From netbeans with Apache License 2.0 5 votes vote down vote up
private boolean canDrag(MouseEvent e) {
    return (e.getModifiersEx() & (MouseEvent.ALT_DOWN_MASK |
                                  MouseEvent.ALT_GRAPH_DOWN_MASK |
                                  MouseEvent.CTRL_DOWN_MASK |
                                  MouseEvent.META_DOWN_MASK |
                                  MouseEvent.SHIFT_DOWN_MASK)) == 0;
}
 
Example 7
Source File: DoubleClickSelectAction.java    From openjdk-jdk9 with GNU General Public License v2.0 5 votes vote down vote up
@Override
public State mousePressed(Widget widget, WidgetMouseEvent event) {
    if (event.getClickCount() >= 2 && (event.getButton() == MouseEvent.BUTTON1 || event.getButton() == MouseEvent.BUTTON2)) {
        boolean invert = (event.getModifiersEx() & MouseEvent.CTRL_DOWN_MASK) != 0;
        Point point = event.getPoint();
        if (provider.isSelectionAllowed(widget, point, invert)) {
            provider.select(widget, point, invert);
            return State.CHAIN_ONLY;
        }
    }
    return State.REJECTED;
}
 
Example 8
Source File: DtdSelectionTool.java    From workcraft with MIT License 5 votes vote down vote up
private TransitionEvent.Direction getDesiredDirection(Signal.State state, int mask) {
    if (state == Signal.State.UNSTABLE) {
        switch (mask) {
        case MouseEvent.SHIFT_DOWN_MASK:
            return TransitionEvent.Direction.RISE;
        case MouseEvent.CTRL_DOWN_MASK:
            return TransitionEvent.Direction.FALL;
        default:
            return TransitionEvent.Direction.STABILISE;
        }
    }
    if (state == Signal.State.HIGH) {
        switch (mask) {
        case MouseEvent.SHIFT_DOWN_MASK | MouseEvent.CTRL_DOWN_MASK:
            return TransitionEvent.Direction.DESTABILISE;
        default:
            return TransitionEvent.Direction.FALL;
        }
    }
    if (state == Signal.State.LOW) {
        switch (mask) {
        case MouseEvent.SHIFT_DOWN_MASK | MouseEvent.CTRL_DOWN_MASK:
            return TransitionEvent.Direction.DESTABILISE;
        default:
            return TransitionEvent.Direction.RISE;
        }
    }
    if (state == Signal.State.STABLE) {
        return TransitionEvent.Direction.DESTABILISE;
    }
    return null;
}
 
Example 9
Source File: KeymapImpl.java    From consulo with Apache License 2.0 5 votes vote down vote up
/**
 * @return string representation of passed mouse shortcut. This method should
 *         be used only for serializing of the <code>MouseShortcut</code>
 */
private static String getMouseShortcutString(MouseShortcut shortcut) {
  StringBuilder buffer = new StringBuilder();

  // modifiers

  int modifiers = shortcut.getModifiers();
  if ((MouseEvent.SHIFT_DOWN_MASK & modifiers) > 0) {
    buffer.append(SHIFT);
    buffer.append(' ');
  }
  if ((MouseEvent.CTRL_DOWN_MASK & modifiers) > 0) {
    buffer.append(CONTROL);
    buffer.append(' ');
  }
  if ((MouseEvent.META_DOWN_MASK & modifiers) > 0) {
    buffer.append(META);
    buffer.append(' ');
  }
  if ((MouseEvent.ALT_DOWN_MASK & modifiers) > 0) {
    buffer.append(ALT);
    buffer.append(' ');
  }
  if ((MouseEvent.ALT_GRAPH_DOWN_MASK & modifiers) > 0) {
    buffer.append(ALT_GRAPH);
    buffer.append(' ');
  }

  // button

  buffer.append("button").append(shortcut.getButton()).append(' ');

  if (shortcut.getClickCount() > 1) {
    buffer.append(DOUBLE_CLICK);
  }
  return buffer.toString().trim(); // trim trailing space (if any)
}
 
Example 10
Source File: DesktopApi.java    From workcraft with MIT License 4 votes vote down vote up
public static int getMenuKeyMouseMask() {
    if (getOs().isMac()) {
        return MouseEvent.META_DOWN_MASK;
    }
    return MouseEvent.CTRL_DOWN_MASK;
}