java.awt.event.KeyEvent.getModifiersEx()方法的使用及代码示例

x33g5p2x  于2022-01-23 转载在 其他  
字(8.3k)|赞(0)|评价(0)|浏览(174)

本文整理了Java中java.awt.event.KeyEvent.getModifiersEx()方法的一些代码示例,展示了KeyEvent.getModifiersEx()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。KeyEvent.getModifiersEx()方法的具体详情如下:
包路径:java.awt.event.KeyEvent
类名称:KeyEvent
方法名:getModifiersEx

KeyEvent.getModifiersEx介绍

暂无

代码示例

代码示例来源:origin: mabe02/lanterna

@Override
public void keyTyped(KeyEvent e) {
  char character = e.getKeyChar();
  boolean altDown = (e.getModifiersEx() & InputEvent.ALT_DOWN_MASK) != 0;
  boolean ctrlDown = (e.getModifiersEx() & InputEvent.CTRL_DOWN_MASK) != 0;
  boolean shiftDown = (e.getModifiersEx() & InputEvent.SHIFT_DOWN_MASK) != 0;
  if(!TYPED_KEYS_TO_IGNORE.contains(character)) {
    //We need to re-adjust alphabet characters if ctrl was pressed, just like for the AnsiTerminal
    if(ctrlDown && character > 0 && character < 0x1a) {
      character = (char) ('a' - 1 + character);
      if(shiftDown) {
        character = Character.toUpperCase(character);
      }
    }
    // Check if clipboard is avavilable and this was a paste (ctrl + shift + v) before
    // adding the key to the input queue
    if(!altDown && ctrlDown && shiftDown && character == 'V' && deviceConfiguration.isClipboardAvailable()) {
      pasteClipboardContent();
    }
    else {
      keyQueue.add(new KeyStroke(character, ctrlDown, altDown, shiftDown));
    }
  }
}

代码示例来源:origin: runelite/runelite

/**
 * Constructs a keybind with that matches the passed KeyEvent
 */
public Keybind(KeyEvent e)
{
  this(e.getExtendedKeyCode(), e.getModifiersEx());
  assert matches(e);
}

代码示例来源:origin: runelite/runelite

/**
 * Constructs a keybind with that matches the passed KeyEvent
 */
public ModifierlessKeybind(KeyEvent e)
{
  this(e.getExtendedKeyCode(), e.getModifiersEx());
  assert matches(e);
}

代码示例来源:origin: groovy/groovy-core

protected void processKeyEvent(KeyEvent e) {
  super.processKeyEvent(e);
  //  Handle release of Insert key to toggle overtype/insert mode
  //  unless a modifier is active (eg Shift+Insert for paste or
  //  Ctrl+Insert for Copy)
  if (e.getID() == KeyEvent.KEY_RELEASED &&
      e.getKeyCode() == KeyEvent.VK_INSERT &&
      e.getModifiersEx() == 0) {
    setOvertypeMode(!isOvertypeMode());
  }
}

代码示例来源:origin: mabe02/lanterna

@Override
public void keyPressed(KeyEvent e) {
  boolean altDown = (e.getModifiersEx() & InputEvent.ALT_DOWN_MASK) != 0;
  boolean ctrlDown = (e.getModifiersEx() & InputEvent.CTRL_DOWN_MASK) != 0;
  boolean shiftDown = (e.getModifiersEx() & InputEvent.SHIFT_DOWN_MASK) != 0;
  if(e.getKeyCode() == KeyEvent.VK_ENTER) {
    keyQueue.add(new KeyStroke(KeyType.Enter, ctrlDown, altDown, shiftDown));

代码示例来源:origin: runelite/runelite

protected boolean matches(KeyEvent e, boolean ignoreModifiers)
{
  if (NOT_SET.equals(this))
  {
    return false;
  }
  int keyCode = e.getExtendedKeyCode();
  int modifiers = e.getModifiersEx() & KEYBOARD_MODIFIER_MASK;
  Integer mf = getModifierForKeyCode(keyCode);
  if (mf != null)
  {
    modifiers |= mf;
    keyCode = KeyEvent.VK_UNDEFINED;
  }
  if (e.getID() == KeyEvent.KEY_RELEASED && keyCode != KeyEvent.VK_UNDEFINED)
  {
    return this.keyCode == keyCode;
  }
  if (ignoreModifiers && keyCode != KeyEvent.VK_UNDEFINED)
  {
    return this.keyCode == keyCode;
  }
  return this.keyCode == keyCode && this.modifiers == modifiers;
}

代码示例来源:origin: geotools/geotools

/**
 * Tests whether the key code and modifiers of this {@code KeyInfo} match that of a given {@code
 * KeyEvent}. For convenience, this method will return {@code false} if the input event is
 * {@code null}.
 *
 * @param e the input event
 * @return {@code true} if the key code and modifier values match those of the input event
 */
public boolean matchesEvent(KeyEvent e) {
  return e != null && e.getKeyCode() == keyCode && (e.getModifiersEx() ^ modifiers) == 0;
}

代码示例来源:origin: nodebox/nodebox

public void keyPressed(KeyEvent e) {
  if (handle != null)
    handle.keyPressed(e.getKeyCode(), e.getModifiersEx());
}

代码示例来源:origin: nodebox/nodebox

public void keyTyped(KeyEvent e) {
  if (handle != null)
    handle.keyTyped(e.getKeyCode(), e.getModifiersEx());
}

代码示例来源:origin: pentaho/mondrian

public void changeSelection(
  int rowIndex, int columnIndex, boolean toggle, boolean extend)
{
  if (columnIndex == 0) {
    AWTEvent currentEvent = EventQueue.getCurrentEvent();
    if (currentEvent instanceof KeyEvent) {
      KeyEvent ke = (KeyEvent) currentEvent;
      int kcode = ke.getKeyCode();
      if (kcode == KeyEvent.VK_TAB) {
        if ((ke.getModifiersEx()
           & InputEvent.SHIFT_DOWN_MASK)
          == InputEvent.SHIFT_DOWN_MASK)
        {
          rowIndex -= 1;
          if (rowIndex < 0) {
            rowIndex = propertyTable.getRowCount() - 1;
          }
        }
        setTableCellFocus(rowIndex);
        return;
      }
    }
  }
  super.changeSelection(rowIndex, columnIndex, toggle, extend);
}

代码示例来源:origin: nodebox/nodebox

public void keyReleased(KeyEvent e) {
  Component c = SwingUtilities.getWindowAncestor(Viewer.this);
  if (c instanceof FullScreenFrame) {
    FullScreenFrame frame = (FullScreenFrame) c;
    if (e.getKeyCode() == KeyEvent.VK_ESCAPE) {
      frame.close();
    } else if (e.getKeyCode() == KeyEvent.VK_P) {
      int metaMask = KeyEvent.META_MASK;
      int metaShiftMask = KeyEvent.META_MASK | KeyEvent.SHIFT_MASK;
      if (e.getModifiers() == metaMask)
        frame.toggleAnimation();
      else if (e.getModifiers() == metaShiftMask)
        frame.rewindAnimation();
    }
  }
  if (handle != null)
    handle.keyReleased(e.getKeyCode(), e.getModifiersEx());
}

代码示例来源:origin: com.google.code.findbugs/findbugs

@Override
  public void keyPressed(KeyEvent e) {
    if (e.getKeyCode() == KeyEvent.VK_ESCAPE) {
      cancelClicked();
    } else if (e.getKeyCode() == KeyEvent.VK_ENTER && (e.getModifiersEx() & InputEvent.CTRL_DOWN_MASK) != 0) {
      submitComment(CloudCommentsPane.this.getSelectedBugs());
    }
  }
});

代码示例来源:origin: elki-project/elki

@Override
public void keyPressed(KeyEvent e) {
 if((e.getModifiersEx() & KeyEvent.CTRL_DOWN_MASK) != 0) {
  if(e.getKeyCode() == KeyEvent.VK_SPACE //
    || e.getKeyCode() == KeyEvent.VK_ENTER //
    || e.getKeyCode() == KeyEvent.VK_DOWN //
    || e.getKeyCode() == KeyEvent.VK_KP_DOWN) {
   e.consume();
   actionPerformed(new ActionEvent(e.getSource(), ActionEvent.ACTION_PERFORMED, "assist"));
  }
 }
}

代码示例来源:origin: freeplane/freeplane

private boolean areEqual(KeyEvent e, KeyStroke currentAccelerator) {
  return currentAccelerator != null
      && e.getKeyCode() == currentAccelerator.getKeyCode()
      && (e.getModifiers() | e.getModifiersEx()) == currentAccelerator.getModifiers();
}

代码示例来源:origin: uk.ac.gate.plugins/annie

@Override
 protected void processKeyEvent(KeyEvent e) {
  if (editable && e.getKeyCode() == KeyEvent.VK_DELETE
  && ((e.getModifiersEx() & KeyEvent.SHIFT_DOWN_MASK) != 0)) {
   new DeleteSelectedGazetteerNodeAction().actionPerformed(null);
  } else {
   super.processKeyEvent(e);
  }
 }
};

代码示例来源:origin: org.codehaus.groovy/groovy-console

protected void processKeyEvent(KeyEvent e) {
  super.processKeyEvent(e);
  //  Handle release of Insert key to toggle overtype/insert mode
  //  unless a modifier is active (eg Shift+Insert for paste or
  //  Ctrl+Insert for Copy)
  if (e.getID() == KeyEvent.KEY_RELEASED &&
      e.getKeyCode() == KeyEvent.VK_INSERT &&
      e.getModifiersEx() == 0) {
    setOvertypeMode(!isOvertypeMode());
  }
}

代码示例来源:origin: com.thinkaurelius.groovy-shaded-asm/groovy-shaded-asm

protected void processKeyEvent(KeyEvent e) {
  super.processKeyEvent(e);
  //  Handle release of Insert key to toggle overtype/insert mode
  //  unless a modifier is active (eg Shift+Insert for paste or
  //  Ctrl+Insert for Copy)
  if (e.getID() == KeyEvent.KEY_RELEASED &&
      e.getKeyCode() == KeyEvent.VK_INSERT &&
      e.getModifiersEx() == 0) {
    setOvertypeMode(!isOvertypeMode());
  }
}

代码示例来源:origin: robo-code/robocode

public void serialize(RbSerializer serializer, ByteBuffer buffer, Object object) {
  KeyTypedEvent obj = (KeyTypedEvent) object;
  java.awt.event.KeyEvent src = obj.getSourceEvent();
  serializer.serialize(buffer, src.getKeyChar());
  serializer.serialize(buffer, src.getKeyCode());
  serializer.serialize(buffer, src.getKeyLocation());
  serializer.serialize(buffer, src.getID());
  serializer.serialize(buffer, src.getModifiersEx());
  serializer.serialize(buffer, src.getWhen());
}

代码示例来源:origin: robo-code/robocode

public void serialize(RbSerializer serializer, ByteBuffer buffer, Object object) {
  KeyPressedEvent obj = (KeyPressedEvent) object;
  java.awt.event.KeyEvent src = obj.getSourceEvent();
  serializer.serialize(buffer, src.getKeyChar());
  serializer.serialize(buffer, src.getKeyCode());
  serializer.serialize(buffer, src.getKeyLocation());
  serializer.serialize(buffer, src.getID());
  serializer.serialize(buffer, src.getModifiersEx());
  serializer.serialize(buffer, src.getWhen());
}

代码示例来源:origin: freeplane/freeplane

protected boolean isSplitActionTriggered(final KeyEvent e) {
  final int keyCode = e.getKeyCode();
  if (keyCode == SPLIT_KEY_CODE && keyCode != -1 && e.isAltDown()&& !e.isAltGraphDown()&& !e.isControlDown() && ! Compat.isMacOsX())
    return true;
  final KeyStroke splitNodeHotKey = ResourceController.getResourceController().getAcceleratorManager().getAccelerator("SplitNode");
  return splitNodeHotKey != null && splitNodeHotKey.getKeyCode() == keyCode  &&
      (e.getModifiersEx() & KEYSTROKE_MODIFIERS)  == (splitNodeHotKey.getModifiers() & KEYSTROKE_MODIFIERS);
}

相关文章