Java Code Examples for java.awt.event.InputEvent.CTRL_MASK

The following are Jave code examples for showing how to use CTRL_MASK of the java.awt.event.InputEvent class. You can vote up the examples you like. Your votes will be used in our system to get more good examples.
+ Save this method
Example 1
Project: openjdk-jdk10   File: EventDispatcher.java   View Source Code Vote up 6 votes
/**
 * Get a string representation for key modifiers. Used to print trace.
 *
 * @param modifiers Bit mask of keyboard event modifiers.
 * @return a string representation for the keyboard event modifiers.
 */
public static String getModifiersString(int modifiers) {
    String result = "";
    if ((modifiers & InputEvent.CTRL_MASK) != 0) {
        result = result + "CTRL_MASK | ";
    }
    if ((modifiers & InputEvent.META_MASK) != 0) {
        result = result + "META_MASK | ";
    }
    if ((modifiers & InputEvent.ALT_MASK) != 0) {
        result = result + "ALT_MASK | ";
    }
    if ((modifiers & InputEvent.ALT_GRAPH_MASK) != 0) {
        result = result + "ALT_GRAPH_MASK | ";
    }
    if ((modifiers & InputEvent.SHIFT_MASK) != 0) {
        result = result + "SHIFT_MASK | ";
    }
    if (result.length() > 0) {
        return result.substring(0, result.length() - 3);
    }
    return result;
}
 
Example 2
Project: incubator-netbeans   File: KeyboardPopupSwitcherTestHid.java   View Source Code Vote up 6 votes
@Override
public boolean dispatchKeyEvent(java.awt.event.KeyEvent e) {
    boolean isCtrl = e.getModifiers() == InputEvent.CTRL_MASK;
    boolean isCtrlShift = e.getModifiers() == (InputEvent.CTRL_MASK | InputEvent.SHIFT_MASK);
    boolean doPopup = (e.getKeyCode() == KeyEvent.VK_TAB) &&
            (isCtrl || isCtrlShift);
    if (doPopup && !KeyboardPopupSwitcher.isShown()) {
        // create popup with our SwitcherTable
        KeyboardPopupSwitcher.showPopup(new Model( items1, items2, true ), KeyEvent.VK_CONTROL, e.getKeyCode(), (e.getModifiers() & InputEvent.SHIFT_MASK)==0);
        return true;
    }
    if( KeyboardPopupSwitcher.isShown() ) {
        KeyboardPopupSwitcher.doProcessShortcut( e );
    }
    
    return false;
}
 
Example 3
Project: openjdk-jdk10   File: bug7170657.java   View Source Code Vote up 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 4
Project: jdk8u-jdk   File: bug7170657.java   View Source Code Vote up 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
Project: marathonv5   File: EventQueueDevice.java   View Source Code Vote up 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 6
Project: openjdk-jdk10   File: AWTKeyStroke.java   View Source Code Vote up 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 7
Project: VASSAL-src   File: RestrictCommands.java   View Source Code Vote up 6 votes
public void mySetType(String type) {
  SequenceEncoder.Decoder st = new SequenceEncoder.Decoder(type, ';');
  st.nextToken();
  name = st.nextToken("");
  action = st.nextToken(HIDE);
  propertyMatch.setExpression(st.nextToken(""));

  String keys = st.nextToken("");
  if (keys.indexOf(',') > 0) {
    watchKeys = NamedKeyStrokeArrayConfigurer.decode(keys);
  }
  else {
    watchKeys = new NamedKeyStroke[keys.length()];
    for (int i = 0; i < watchKeys.length; i++) {
      watchKeys[i] = new NamedKeyStroke(keys.charAt(i),InputEvent.CTRL_MASK);
    }
  }
}
 
Example 8
Project: openjdk-jdk10   File: ModifierRobotKeyTest.java   View Source Code Vote up 5 votes
public ModifierRobotKeyTest() throws Exception {
    modifierKeys =  new int[4];
    modifierKeys[0] = KeyEvent.VK_SHIFT;
    modifierKeys[1] = KeyEvent.VK_CONTROL;
    modifierKeys[2] = KeyEvent.VK_ALT;
    modifierKeys[3] = KeyEvent.VK_ALT_GRAPH;

    inputMasks = new int[4];
    inputMasks[0] =  InputEvent.SHIFT_MASK;
    inputMasks[1] =  InputEvent.CTRL_MASK;
    inputMasks[2] =  InputEvent.ALT_MASK;
    inputMasks[3] =  InputEvent.ALT_GRAPH_MASK;

    modifierStatus = new boolean[modifierKeys.length];

    textKeys = new int[2];
    textKeys[0] = KeyEvent.VK_A;

    String os = System.getProperty("os.name").toLowerCase();

    if (os.contains("solaris") || os.contains("sunos"))
        textKeys[1] = KeyEvent.VK_S;
    else if (os.contains("os x"))
        textKeys[1] = KeyEvent.VK_K;
    else
        textKeys[1] = KeyEvent.VK_I;

    textStatus = new boolean[textKeys.length];

    EventQueue.invokeAndWait( () -> { initializeGUI(); });
}
 
Example 9
Project: jdk8u-jdk   File: AWTKeyStroke.java   View Source Code Vote up 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
Project: rapidminer   File: JEditTextArea.java   View Source Code Vote up 5 votes
private void doSingleClick(MouseEvent evt, int line, int offset, int dot) {
	if ((evt.getModifiers() & InputEvent.SHIFT_MASK) != 0) {
		rectSelect = (evt.getModifiers() & InputEvent.CTRL_MASK) != 0;
		select(getMarkPosition(), dot);
	} else {
		setCaretPosition(dot);
	}
}
 
Example 11
Project: marathonv5   File: KeyStrokeParser.java   View Source Code Vote up 5 votes
private int getModifier(int keycode) {
    switch (keycode) {
    case KeyEvent.VK_SHIFT:
        return InputEvent.SHIFT_MASK;
    case KeyEvent.VK_CONTROL:
        return InputEvent.CTRL_MASK;
    case KeyEvent.VK_ALT:
        return InputEvent.ALT_MASK;
    case KeyEvent.VK_META:
        return InputEvent.META_MASK;
    default:
        throw new RuntimeException(OSUtils.keyEventGetKeyText(keycode) + " is not a valid modifier");
    }
}
 
Example 12
Project: VASSAL-src   File: EmbellishmentSerializeTest.java   View Source Code Vote up 5 votes
@Test
public void serialize() throws Exception {
  Embellishment emb = new Embellishment();
  emb.activateCommand = "testActivateCommand";
  emb.activateModifiers = InputEvent.CTRL_MASK;
  emb.activateKey = "testActivateKey";
  emb.upCommand = "testUpCommand";
  emb.upModifiers = InputEvent.CTRL_MASK;
  emb.upKey = "testUpKey";
  emb.downCommand = "testDownCommand";
  emb.downModifiers = InputEvent.CTRL_MASK;
  emb.downKey = "testDownKey";
  emb.resetKey = new NamedKeyStroke("A");
  emb.resetLevel = new FormattedString("resetLevel");
  emb.drawUnderneathWhenSelected = true;
  emb.xOff = 1;
  emb.yOff = 2;
  emb.imageName = new String[] {"imageName1", "imageName2"};
  emb.commonName = new String[] {"commonName1", "commonName2"};
  emb.loopLevels = true;
  emb.name = "testName";
  emb.rndKey = new NamedKeyStroke("B");
  emb.followProperty = true;
  emb.propertyName = "testPropertyName";
  emb.firstLevelValue = 3;
  emb.version = 4;
  emb.alwaysActive = true;
  emb.activateKeyStroke = new NamedKeyStroke("C");
  emb.increaseKeyStroke = new NamedKeyStroke("D");
  emb.decreaseKeyStroke = new NamedKeyStroke("E");

  super.serializeTest(Embellishment.class, emb);
}
 
Example 13
Project: intellij-randomness   File: DataGroupAction.java   View Source Code Vote up 5 votes
@Override
@SuppressWarnings("PMD.ConfusingTernary") // != 0 for binary mask is expected
public final void actionPerformed(final AnActionEvent event) {
    super.actionPerformed(event);

    if ((event.getModifiers() & (InputEvent.SHIFT_MASK | InputEvent.SHIFT_DOWN_MASK)) != 0) {
        getInsertArrayAction().actionPerformed(event);
    } else if ((event.getModifiers() & (InputEvent.CTRL_MASK | InputEvent.CTRL_DOWN_MASK)) != 0) {
        getSettingsAction().actionPerformed(event);
    } else {
        getInsertAction().actionPerformed(event);
    }
}
 
Example 14
Project: TrabalhoFinalEDA2   File: mxGraphHandler.java   View Source Code Vote up 5 votes
/**
 * 
 */
protected MouseEvent createEvent(DropTargetEvent e)
{
	JComponent component = getDropTarget(e);
	Point location = null;
	int action = 0;

	if (e instanceof DropTargetDropEvent)
	{
		location = ((DropTargetDropEvent) e).getLocation();
		action = ((DropTargetDropEvent) e).getDropAction();
	}
	else if (e instanceof DropTargetDragEvent)
	{
		location = ((DropTargetDragEvent) e).getLocation();
		action = ((DropTargetDragEvent) e).getDropAction();
	}

	if (location != null)
	{
		location = convertPoint(location);
		Rectangle r = graphComponent.getViewport().getViewRect();
		location.translate(r.x, r.y);
	}

	// LATER: Fetch state of modifier keys from event or via global
	// key listener using Toolkit.getDefaultToolkit().addAWTEventListener(
	// new AWTEventListener() {...}, AWTEvent.KEY_EVENT_MASK). Problem
	// is the event does not contain the modifier keys and the global
	// handler is not called during drag and drop.
	int mod = (action == TransferHandler.COPY) ? InputEvent.CTRL_MASK : 0;

	return new MouseEvent(component, 0, System.currentTimeMillis(), mod,
			location.x, location.y, 1, false, MouseEvent.BUTTON1);
}
 
Example 15
Project: incubator-netbeans   File: ListView.java   View Source Code Vote up 4 votes
/** This method is called when user double-clicks on some object or
* presses Enter key.
* @param index Index of object in current explored context
*/
final void performObjectAt(int index, int modifiers) {
    if ((index < 0) || (index >= model.getSize())) {
        return;
    }

    VisualizerNode v = (VisualizerNode) model.getElementAt(index);
    Node node = v.node;

    // if DefaultProcessor is set, the default action is notified to it overriding the default action on nodes
    if (defaultProcessor != null) {
        defaultProcessor.actionPerformed(new ActionEvent(node, 0, null, modifiers));

        return;
    }

    if (showParentNode && NodeListModel.findVisualizerDepth(model, v) == -1) {
        try {
            manager.setExploredContextAndSelection(node.getParentNode(), new Node[] { node });
        } catch (PropertyVetoException ex) {
            // OK, let it be
        }
        return;
    }

    // on double click - invoke default action, if there is any
    // (unless user holds CTRL key what means that we should always dive into the context)
    Action a = node.getPreferredAction();

    if ((a != null) && ((modifiers & InputEvent.CTRL_MASK) == 0)) {
        a = TreeView.takeAction(a, node);

        if (a.isEnabled()) {
            a.actionPerformed(new ActionEvent(node, ActionEvent.ACTION_PERFORMED, "")); // NOI18N
        } else {
            Utilities.disabledActionBeep();
        }
    }
    // otherwise dive into the context
    else if (traversalAllowed && (!node.isLeaf())) {
        manager.setExploredContext(node, manager.getSelectedNodes());
    }
}
 
Example 16
Project: jdk8u-jdk   File: LWCToolkit.java   View Source Code Vote up 4 votes
/**
 * Returns key modifiers used by Swing to set up a focus accelerator key
 * stroke.
 */
@Override
public int getFocusAcceleratorKeyMask() {
    return InputEvent.CTRL_MASK | InputEvent.ALT_MASK;
}
 
Example 17
Project: WordnetLoom   File: ViwnGraphViewModalGraphMouse.java   View Source Code Vote up 4 votes
public ViwnPickingGraphMousePlugin() {
    super(InputEvent.BUTTON1_MASK, InputEvent.BUTTON1_MASK | InputEvent.CTRL_MASK);
    cursor = Cursor.getPredefinedCursor(Cursor.DEFAULT_CURSOR);
}
 
Example 18
Project: VASSAL-src   File: Embellishment0.java   View Source Code Vote up 4 votes
/**
 * This original way of representing the type causes problems because it's not
 * extensible
 *
 * @param s
 */
private void originalSetType(String s) {
  SequenceEncoder.Decoder st = new SequenceEncoder.Decoder(s, ';');

  st.nextToken();
  final SequenceEncoder.Decoder st2 =
    new SequenceEncoder.Decoder(st.nextToken(), ';');
  activateKey = st2.nextToken().toUpperCase();
  activateModifiers = InputEvent.CTRL_MASK;
  if (st2.hasMoreTokens()) {
    resetCommand = st2.nextToken();
    resetKey = st2.nextKeyStroke(null);
    resetLevel.setFormat(st2.nextToken("0"));
  }
  else {
    resetKey = null;
    resetCommand = "";
    resetLevel.setFormat("0");
  }

  activateCommand = st.nextToken();
  drawUnderneathWhenSelected = activateCommand.startsWith("_");
  if (drawUnderneathWhenSelected) {
    activateCommand = activateCommand.substring(1);
  }

  value = activateKey.length() > 0 ? -1 : 1;

  upKey = st.nextToken().toUpperCase();
  upCommand = st.nextToken();
  upModifiers = InputEvent.CTRL_MASK;

  downKey = st.nextToken().toUpperCase();
  downCommand = st.nextToken();
  downModifiers = InputEvent.CTRL_MASK;

  xOff = st.nextInt(0);
  yOff = st.nextInt(0);

  final ArrayList<String> l = new ArrayList<String>();
  while (st.hasMoreTokens()) {
    l.add(st.nextToken());
  }

  nValues = l.size();
  imageName = new String[l.size()];
  commonName = new String[l.size()];
  size = new Rectangle[imageName.length];
  imagePainter = new ScaledImagePainter[imageName.length];

  for (int i = 0; i < imageName.length; ++i) {
    final String sub = l.get(i);
    final SequenceEncoder.Decoder subSt =
      new SequenceEncoder.Decoder(sub, ',');
    imageName[i] = subSt.nextToken();
    imagePainter[i] = new ScaledImagePainter();
    imagePainter[i].setImageName(imageName[i]);
    if (subSt.hasMoreTokens()) {
      commonName[i] = subSt.nextToken();
    }
  }
  loopLevels = true;
}
 
Example 19
Project: openjdk-jdk10   File: SunToolkit.java   View Source Code Vote up 2 votes
/**
 * Tests whether specified key modifiers mask can be used to enter a printable
 * character. This is a default implementation of this method, which reflects
 * the way things work on Windows: here, pressing ctrl + alt allows user to enter
 * characters from the extended character set (like euro sign or math symbols)
 */
@SuppressWarnings("deprecation")
public boolean isPrintableCharacterModifiersMask(int mods) {
    return ((mods & InputEvent.ALT_MASK) == (mods & InputEvent.CTRL_MASK));
}
 
Example 20
Project: OpenJSharp   File: SunToolkit.java   View Source Code Vote up 2 votes
/**
 * Tests whether specified key modifiers mask can be used to enter a printable
 * character. This is a default implementation of this method, which reflects
 * the way things work on Windows: here, pressing ctrl + alt allows user to enter
 * characters from the extended character set (like euro sign or math symbols)
 */
public boolean isPrintableCharacterModifiersMask(int mods) {
    return ((mods & InputEvent.ALT_MASK) == (mods & InputEvent.CTRL_MASK));
}