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

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

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

KeyEvent.isPrintableKey介绍

[英]Returns true if #getKeySymbol() and #getKeyChar()represents a printable character, i.e. a value other than #VK_UNDEFINEDand not a control or non-printable private code.

A printable character is neither a #isModifierKey(short), nor an #isActionKey(short).

Otherwise returns false.
[中]如果#getKeySymbol()和#getKeyChar()表示可打印字符,即除#VK_未定义且不是控件或不可打印的专用代码之外的值,则返回true
可打印字符既不是#isModifierKey(短),也不是#isActionKey(短)。
否则返回false

代码示例

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

private char NewtVKey2Unicode(final short VK, final int modifiers) {
  if( KeyEvent.isPrintableKey(VK, true) ) {
    if((modifiers & InputEvent.SHIFT_MASK) == InputEvent.SHIFT_MASK) {
      return (char)VK;
    } else {
      return String.valueOf((char)VK).toLowerCase().charAt(0);
    }
  }
  return 0;
}

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

private char NewtVKey2Unicode(final short VK, final int modifiers) {
  if( KeyEvent.isPrintableKey(VK, true) ) {
    if((modifiers & InputEvent.SHIFT_MASK) == InputEvent.SHIFT_MASK) {
      return (char)VK;
    } else {
      return String.valueOf((char)VK).toLowerCase().charAt(0);
    }
  }
  return 0;
}

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

private KeyEvent(final short eventType, final Object source, final long when, final int modifiers, final short keyCode, final short keySym, final int keySymModMask, final char keyChar) {
  super(eventType, source, when, modifiers | keySymModMask);
  this.keyCode=keyCode;
  this.keySym=keySym;
  this.keyChar=keyChar;
  { // cache modifier and action flags
    byte _flags = 0;
    if( isPrintableKey(keySym, false) && isPrintableKey((short)keyChar, true) ) {
      _flags |= F_PRINTABLE_MASK;
    } else {
      if( 0 != keySymModMask ) {
        _flags |= F_MODIFIER_MASK;
      } else {
        // A = U - ( P + M )
        _flags |= F_ACTION_MASK;
      }
    }
    flags = _flags;
    //
    // Validate flags
    //
    final int pma_bits = flags & ( F_PRINTABLE_MASK | F_MODIFIER_MASK | F_ACTION_MASK ) ;
    final int pma_count = IntBitfield.getBitCount(pma_bits);
    if ( 1 != pma_count ) {
      throw new InternalError("Key must be either of type printable, modifier or action - but it is of "+pma_count+" types: "+this);
    }
  }
}

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

private KeyEvent(final short eventType, final Object source, final long when, final int modifiers, final short keyCode, final short keySym, final int keySymModMask, final char keyChar) {
  super(eventType, source, when, modifiers | keySymModMask);
  this.keyCode=keyCode;
  this.keySym=keySym;
  this.keyChar=keyChar;
  { // cache modifier and action flags
    byte _flags = 0;
    if( isPrintableKey(keySym, false) && isPrintableKey((short)keyChar, true) ) {
      _flags |= F_PRINTABLE_MASK;
    } else {
      if( 0 != keySymModMask ) {
        _flags |= F_MODIFIER_MASK;
      } else {
        // A = U - ( P + M )
        _flags |= F_ACTION_MASK;
      }
    }
    flags = _flags;
    //
    // Validate flags
    //
    final int pma_bits = flags & ( F_PRINTABLE_MASK | F_MODIFIER_MASK | F_ACTION_MASK ) ;
    final int pma_count = Bitfield.Util.bitCount(pma_bits);
    if ( 1 != pma_count ) {
      throw new InternalError("Key must be either of type printable, modifier or action - but it is of "+pma_count+" types: "+this);
    }
  }
}

代码示例来源: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: org.jogamp.jogl/jogl-all-noawt

@Override
public void keyPressed(final KeyEvent e) {
  if( !e.isPrintableKey() || e.isAutoRepeat() ) {
    return;
  }
  if(e.getKeyChar()=='r' && 0==e.getModifiers() && null!=parentWin) {
    e.setConsumed(true);
    glWindow.invokeOnNewThread(null, false, new Runnable() {
      public void run() {
        if(null == glWindow.getParent()) {
          glWindow.reparentWindow(parentWin, -1, -1, 0 /* hints */);
       } else {
          final InsetsImmutable insets = glWindow.getInsets();
          final int x, y;
          if ( 0 >= insets.getTopHeight() ) {
            // fail safe ..
            x = 32;
            y = 32;
          } else {
            x = insets.getLeftWidth();
            y = insets.getTopHeight();
          }
          glWindow.reparentWindow(null, x, y, 0 /* hints */);
          glWindow.setDefaultCloseOperation( glClosable ? WindowClosingMode.DISPOSE_ON_CLOSE : WindowClosingMode.DO_NOTHING_ON_CLOSE );
        }
      } } );
  }
}

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

@Override
public void keyPressed(final KeyEvent e) {
  if( !e.isPrintableKey() || e.isAutoRepeat() ) {
    return;

相关文章