android.view.KeyEvent.getKeyData()方法的使用及代码示例

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

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

KeyEvent.getKeyData介绍

暂无

代码示例

代码示例来源:origin: ZieIony/Carbon

final KeyCharacterMap.KeyData possibleChars = new KeyCharacterMap.KeyData();
event.getKeyData(possibleChars);

代码示例来源:origin: ZieIony/Carbon

@SuppressWarnings("deprecation")
void findItemsWithShortcutForKey(List<MenuItem> items, int keyCode, KeyEvent event) {
  final boolean qwerty = isQwertyMode();
  final int metaState = event.getMetaState();
  final KeyCharacterMap.KeyData possibleChars = new KeyCharacterMap.KeyData();
  // Get the chars associated with the keyCode (i.e using any chording combo)
  final boolean isKeyCodeMapped = event.getKeyData(possibleChars);
  // The delete key is not mapped to '\b' so we treat it specially
  if (!isKeyCodeMapped && (keyCode != KeyEvent.KEYCODE_DEL)) {
    return;
  }
  // Look for an item whose shortcut is this key.
  final int N = mItems.size();
  for (int i = 0; i < N; i++) {
    MenuItem item = mItems.get(i);
    if (item.hasSubMenu()) {
      ((Menu) item.getSubMenu()).findItemsWithShortcutForKey(items, keyCode, event);
    }
    final char shortcutChar = qwerty ? item.getAlphabeticShortcut() : item.getNumericShortcut();
    if (((metaState & (KeyEvent.META_SHIFT_ON | KeyEvent.META_SYM_ON)) == 0) &&
        (shortcutChar != 0) &&
        (shortcutChar == possibleChars.meta[0]
            || shortcutChar == possibleChars.meta[2]
            || (qwerty && shortcutChar == '\b' &&
            keyCode == KeyEvent.KEYCODE_DEL)) &&
        item.isEnabled()) {
      items.add(item);
    }
  }
}

代码示例来源:origin: com.willowtreeapps/oak-demos

final KeyCharacterMap.KeyData possibleChars = new KeyCharacterMap.KeyData();
event.getKeyData(possibleChars);

代码示例来源:origin: com.actionbarsherlock/actionbarsherlock

final KeyCharacterMap.KeyData possibleChars = new KeyCharacterMap.KeyData();
event.getKeyData(possibleChars);

代码示例来源:origin: com.actionbarsherlock/actionbarsherlock

@SuppressWarnings("deprecation")
void findItemsWithShortcutForKey(List<MenuItemImpl> items, int keyCode, KeyEvent event) {
  final boolean qwerty = isQwertyMode();
  final int metaState = event.getMetaState();
  final KeyCharacterMap.KeyData possibleChars = new KeyCharacterMap.KeyData();
  // Get the chars associated with the keyCode (i.e using any chording combo)
  final boolean isKeyCodeMapped = event.getKeyData(possibleChars);
  // The delete key is not mapped to '\b' so we treat it specially
  if (!isKeyCodeMapped && (keyCode != KeyEvent.KEYCODE_DEL)) {
    return;
  }
  // Look for an item whose shortcut is this key.
  final int N = mItems.size();
  for (int i = 0; i < N; i++) {
    MenuItemImpl item = mItems.get(i);
    if (item.hasSubMenu()) {
      ((MenuBuilder)item.getSubMenu()).findItemsWithShortcutForKey(items, keyCode, event);
    }
    final char shortcutChar = qwerty ? item.getAlphabeticShortcut() : item.getNumericShortcut();
    if (((metaState & (KeyEvent.META_SHIFT_ON | KeyEvent.META_SYM_ON)) == 0) &&
       (shortcutChar != 0) &&
       (shortcutChar == possibleChars.meta[0]
         || shortcutChar == possibleChars.meta[2]
         || (qwerty && shortcutChar == '\b' &&
           keyCode == KeyEvent.KEYCODE_DEL)) &&
       item.isEnabled()) {
      items.add(item);
    }
  }
}

代码示例来源:origin: com.willowtreeapps/oak-demos

@SuppressWarnings("deprecation")
void findItemsWithShortcutForKey(List<MenuItemImpl> items, int keyCode, KeyEvent event) {
  final boolean qwerty = isQwertyMode();
  final int metaState = event.getMetaState();
  final KeyCharacterMap.KeyData possibleChars = new KeyCharacterMap.KeyData();
  // Get the chars associated with the keyCode (i.e using any chording combo)
  final boolean isKeyCodeMapped = event.getKeyData(possibleChars);
  // The delete key is not mapped to '\b' so we treat it specially
  if (!isKeyCodeMapped && (keyCode != KeyEvent.KEYCODE_DEL)) {
    return;
  }
  // Look for an item whose shortcut is this key.
  final int N = mItems.size();
  for (int i = 0; i < N; i++) {
    MenuItemImpl item = mItems.get(i);
    if (item.hasSubMenu()) {
      ((MenuBuilder)item.getSubMenu()).findItemsWithShortcutForKey(items, keyCode, event);
    }
    final char shortcutChar = qwerty ? item.getAlphabeticShortcut() : item.getNumericShortcut();
    if (((metaState & (KeyEvent.META_SHIFT_ON | KeyEvent.META_SYM_ON)) == 0) &&
       (shortcutChar != 0) &&
       (shortcutChar == possibleChars.meta[0]
         || shortcutChar == possibleChars.meta[2]
         || (qwerty && shortcutChar == '\b' &&
           keyCode == KeyEvent.KEYCODE_DEL)) &&
       item.isEnabled()) {
      items.add(item);
    }
  }
}

相关文章