com.jogamp.newt.event.KeyEvent.isModifierKey()方法的使用及代码示例

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

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

KeyEvent.isModifierKey介绍

[英]Returns true if #getKeySymbol() represents a modifier key, otherwise false.

See #isModifierKey(short) for details.

Note: Implementation uses a cached value.
[中]如果#getKeySymbol()表示修改器键,则返回true,否则返回false
有关详细信息,请参见#isModifierKey(缩写)。
注意:实现使用缓存值。

代码示例

代码示例来源:origin: ch.unibas.cs.gravis/scalismo-native-stub

@Override
public final StringBuilder toString(StringBuilder sb) {
  if(null == sb) {
    sb = new StringBuilder();
  }
  sb.append("KeyEvent[").append(getEventTypeString(getEventType())).append(", code ").append(toHexString(keyCode)).append(", sym ").append(toHexString(keySym)).append(", char '").append(keyChar).append("' (").append(toHexString((short)keyChar))
  .append("), printable ").append(isPrintableKey()).append(", modifier ").append(isModifierKey()).append(", action ").append(isActionKey()).append(", ");
  return super.toString(sb).append("]");
}

代码示例来源:origin: org.jogamp.jogl/jogl-all-noawt

@Override
public final StringBuilder toString(StringBuilder sb) {
  if(null == sb) {
    sb = new StringBuilder();
  }
  sb.append("KeyEvent[").append(getEventTypeString(getEventType())).append(", code ").append(toHexString(keyCode)).append(", sym ").append(toHexString(keySym)).append(", char '").append(keyChar).append("' (").append(toHexString((short)keyChar))
  .append("), printable ").append(isPrintableKey()).append(", modifier ").append(isModifierKey()).append(", action ").append(isActionKey()).append(", ");
  return super.toString(sb).append("]");
}

代码示例来源:origin: ch.unibas.cs.gravis/scalismo-native-stub

/** Called by native TK */
protected final void sendKeyEvent(final short eventType, final int modifiers, final short keyCode, final short keySym, final char keyChar0, final String keyString) {
  // handleKeyEvent(true, false, eventType, modifiers, keyCode, keyChar);
  final boolean isModifierKey = KeyEvent.isModifierKey(keyCode);
  final boolean isAutoRepeat = 0 != ( InputEvent.AUTOREPEAT_MASK & modifiers );
  final char keyChar =  ( null != keyString ) ? keyString.charAt(0) : keyChar0;
  // System.err.println("*** sendKeyEvent: event "+KeyEvent.getEventTypeString(eventType)+", keyCode "+toHexString(keyCode)+", keyChar <"+keyChar0+">/<"+keyChar+">, keyString "+keyString+", mods "+toHexString(modifiers)+
  //                    ", isKeyCodeTracked "+isKeyCodeTracked(keyCode)+", was: pressed "+isKeyPressed(keyCode)+", repeat "+isAutoRepeat+", [modifierKey "+isModifierKey+"] - "+System.currentTimeMillis());
  if( !isAutoRepeat || !isModifierKey ) { // ! (  isModifierKey && isAutoRepeat )
    switch(eventType) {
      case KeyEvent.EVENT_KEY_PRESSED:
        super.sendKeyEvent(KeyEvent.EVENT_KEY_PRESSED, modifiers, keyCode, keySym, keyChar);
        break;
      case KeyEvent.EVENT_KEY_RELEASED:
        super.sendKeyEvent(KeyEvent.EVENT_KEY_RELEASED, modifiers, keyCode, keySym, keyChar);
        break;
    }
  }
}

代码示例来源:origin: org.jogamp.jogl/jogl-all-noawt

/** Called by native TK */
protected final void sendKeyEvent(final short eventType, final int modifiers, final short keyCode, final short keySym, final char keyChar0, final String keyString) {
  // handleKeyEvent(true, false, eventType, modifiers, keyCode, keyChar);
  final boolean isModifierKey = KeyEvent.isModifierKey(keyCode);
  final boolean isAutoRepeat = 0 != ( InputEvent.AUTOREPEAT_MASK & modifiers );
  final char keyChar =  ( null != keyString ) ? keyString.charAt(0) : keyChar0;
  // System.err.println("*** sendKeyEvent: event "+KeyEvent.getEventTypeString(eventType)+", keyCode "+toHexString(keyCode)+", keyChar <"+keyChar0+">/<"+keyChar+">, keyString "+keyString+", mods "+toHexString(modifiers)+
  //                    ", isKeyCodeTracked "+isKeyCodeTracked(keyCode)+", was: pressed "+isKeyPressed(keyCode)+", repeat "+isAutoRepeat+", [modifierKey "+isModifierKey+"] - "+System.currentTimeMillis());
  if( !isAutoRepeat || !isModifierKey ) { // ! (  isModifierKey && isAutoRepeat )
    switch(eventType) {
      case KeyEvent.EVENT_KEY_PRESSED:
        super.sendKeyEvent(KeyEvent.EVENT_KEY_PRESSED, modifiers, keyCode, keySym, keyChar);
        break;
      case KeyEvent.EVENT_KEY_RELEASED:
        super.sendKeyEvent(KeyEvent.EVENT_KEY_RELEASED, modifiers, keyCode, keySym, keyChar);
        break;
    }
  }
}

代码示例来源:origin: ch.unibas.cs.gravis/scalismo-native-stub

@Override
public final void sendKeyEvent(final short eventType, final int modifiers, final short keyCode, final short keySym, final char keyChar) {
  final boolean isModifierKey = KeyEvent.isModifierKey(keySym);
  // System.err.println("*** sendKeyEvent: event "+KeyEvent.getEventTypeString(eventType)+", keyCode "+toHexString(keyCode)+", keyChar <"+keyChar+">, mods "+toHexString(modifiers)+
  //                   ", isKeyCodeTracked "+isKeyCodeTracked(keyCode)+", was: pressed "+isKeyPressed(keyCode)+", printableKey "+KeyEvent.isPrintableKey(keyCode, false)+" [modifierKey "+isModifierKey+"] - "+System.currentTimeMillis());
  // Reorder: WINDOWS delivery order is PRESSED (t0), TYPED (t0) and RELEASED (t1) -> NEWT order: PRESSED (t0) and RELEASED (t1)
  // Auto-Repeat: WINDOWS delivers only PRESSED (t0) and TYPED (t0).
  switch(eventType) {
    case KeyEvent.EVENT_KEY_RELEASED:
      if( isKeyCodeTracked(keyCode) ) {
        if( repeatedKey == keyCode && !isModifierKey ) {
          // AR out - send out missing PRESSED
          super.sendKeyEvent(KeyEvent.EVENT_KEY_PRESSED, modifiers | InputEvent.AUTOREPEAT_MASK, keyCode, keySym, keyChar);
        }
        setKeyPressed(keyCode, false);
        repeatedKey = KeyEvent.VK_UNDEFINED;
      }
      super.sendKeyEvent(KeyEvent.EVENT_KEY_RELEASED, modifiers, keyCode, keySym, keyChar);
      break;
    case KeyEvent.EVENT_KEY_PRESSED:
      if( !handlePressTypedAutoRepeat(isModifierKey, modifiers, keyCode, keySym, keyChar) ) {
        super.sendKeyEvent(KeyEvent.EVENT_KEY_PRESSED, modifiers, keyCode, keySym, keyChar);
      }
      break;
  }
}

代码示例来源:origin: org.jogamp.jogl/jogl-all-noawt

@Override
public final void sendKeyEvent(final short eventType, final int modifiers, final short keyCode, final short keySym, final char keyChar) {
  final boolean isModifierKey = KeyEvent.isModifierKey(keySym);
  // System.err.println("*** sendKeyEvent: event "+KeyEvent.getEventTypeString(eventType)+", keyCode "+toHexString(keyCode)+", keyChar <"+keyChar+">, mods "+toHexString(modifiers)+
  //                   ", isKeyCodeTracked "+isKeyCodeTracked(keyCode)+", was: pressed "+isKeyPressed(keyCode)+", printableKey "+KeyEvent.isPrintableKey(keyCode, false)+" [modifierKey "+isModifierKey+"] - "+System.currentTimeMillis());
  // Reorder: WINDOWS delivery order is PRESSED (t0), TYPED (t0) and RELEASED (t1) -> NEWT order: PRESSED (t0) and RELEASED (t1)
  // Auto-Repeat: WINDOWS delivers only PRESSED (t0) and TYPED (t0).
  switch(eventType) {
    case KeyEvent.EVENT_KEY_RELEASED:
      if( isKeyCodeTracked(keyCode) ) {
        if( repeatedKey == keyCode && !isModifierKey ) {
          // AR out - send out missing PRESSED
          super.sendKeyEvent(KeyEvent.EVENT_KEY_PRESSED, modifiers | InputEvent.AUTOREPEAT_MASK, keyCode, keySym, keyChar);
        }
        setKeyPressed(keyCode, false);
        repeatedKey = KeyEvent.VK_UNDEFINED;
      }
      super.sendKeyEvent(KeyEvent.EVENT_KEY_RELEASED, modifiers, keyCode, keySym, keyChar);
      break;
    case KeyEvent.EVENT_KEY_PRESSED:
      if( !handlePressTypedAutoRepeat(isModifierKey, modifiers, keyCode, keySym, keyChar) ) {
        super.sendKeyEvent(KeyEvent.EVENT_KEY_PRESSED, modifiers, keyCode, keySym, keyChar);
      }
      break;
  }
}

相关文章