當前位置: 首頁>>代碼示例>>Java>>正文


Java KeyEvent.getKeyData方法代碼示例

本文整理匯總了Java中android.view.KeyEvent.getKeyData方法的典型用法代碼示例。如果您正苦於以下問題:Java KeyEvent.getKeyData方法的具體用法?Java KeyEvent.getKeyData怎麽用?Java KeyEvent.getKeyData使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在android.view.KeyEvent的用法示例。


在下文中一共展示了KeyEvent.getKeyData方法的4個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: findItemsWithShortcutForKey

import android.view.KeyEvent; //導入方法依賴的package包/類
void findItemsWithShortcutForKey(List<MenuItemImpl> items, int keyCode, KeyEvent event) {
    boolean qwerty = isQwertyMode();
    int metaState = event.getMetaState();
    KeyData possibleChars = new KeyData();
    if (event.getKeyData(possibleChars) || keyCode == 67) {
        int N = this.mItems.size();
        for (int i = 0; i < N; i++) {
            MenuItemImpl item = (MenuItemImpl) this.mItems.get(i);
            if (item.hasSubMenu()) {
                ((MenuBuilder) item.getSubMenu()).findItemsWithShortcutForKey(items, keyCode, event);
            }
            char shortcutChar = qwerty ? item.getAlphabeticShortcut() : item.getNumericShortcut();
            if ((metaState & 5) == 0 && shortcutChar != '\u0000' && ((shortcutChar == possibleChars.meta[0] || shortcutChar == possibleChars.meta[2] || (qwerty && shortcutChar == '\b' && keyCode == 67)) && item.isEnabled())) {
                items.add(item);
            }
        }
    }
}
 
開發者ID:JackChan1999,項目名稱:boohee_v5.6,代碼行數:19,代碼來源:MenuBuilder.java

示例2: findItemWithShortcutForKey

import android.view.KeyEvent; //導入方法依賴的package包/類
MenuItemImpl findItemWithShortcutForKey(int keyCode, KeyEvent event) {
    ArrayList<MenuItemImpl> items = this.mTempShortcutItemList;
    items.clear();
    findItemsWithShortcutForKey(items, keyCode, event);
    if (items.isEmpty()) {
        return null;
    }
    int metaState = event.getMetaState();
    KeyData possibleChars = new KeyData();
    event.getKeyData(possibleChars);
    int size = items.size();
    if (size == 1) {
        return (MenuItemImpl) items.get(0);
    }
    boolean qwerty = isQwertyMode();
    for (int i = 0; i < size; i++) {
        MenuItemImpl item = (MenuItemImpl) items.get(i);
        char shortcutChar = qwerty ? item.getAlphabeticShortcut() : item.getNumericShortcut();
        if ((shortcutChar == possibleChars.meta[0] && (metaState & 2) == 0) || ((shortcutChar == possibleChars.meta[2] && (metaState & 2) != 0) || (qwerty && shortcutChar == '\b' && keyCode == 67))) {
            return item;
        }
    }
    return null;
}
 
開發者ID:JackChan1999,項目名稱:boohee_v5.6,代碼行數:25,代碼來源:MenuBuilder.java

示例3: findItemsWithShortcutForKey

import android.view.KeyEvent; //導入方法依賴的package包/類
@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);
        }
    }
}
 
開發者ID:treasure-lau,項目名稱:CSipSimple,代碼行數:32,代碼來源:MenuBuilder.java

示例4: findItemWithShortcutForKey

import android.view.KeyEvent; //導入方法依賴的package包/類
@SuppressWarnings("deprecation")
MenuItemImpl findItemWithShortcutForKey(int keyCode, KeyEvent event) {
    // Get all items that can be associated directly or indirectly with the keyCode
    ArrayList<MenuItemImpl> items = mTempShortcutItemList;
    items.clear();
    findItemsWithShortcutForKey(items, keyCode, event);

    if (items.isEmpty()) {
        return null;
    }

    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)
    event.getKeyData(possibleChars);

    // If we have only one element, we can safely returns it
    final int size = items.size();
    if (size == 1) {
        return items.get(0);
    }

    final boolean qwerty = isQwertyMode();
    // If we found more than one item associated with the key,
    // we have to return the exact match
    for (int i = 0; i < size; i++) {
        final MenuItemImpl item = items.get(i);
        final char shortcutChar = qwerty ? item.getAlphabeticShortcut() :
                item.getNumericShortcut();
        if ((shortcutChar == possibleChars.meta[0] &&
                (metaState & KeyEvent.META_ALT_ON) == 0)
            || (shortcutChar == possibleChars.meta[2] &&
                (metaState & KeyEvent.META_ALT_ON) != 0)
            || (qwerty && shortcutChar == '\b' &&
                keyCode == KeyEvent.KEYCODE_DEL)) {
            return item;
        }
    }
    return null;
}
 
開發者ID:treasure-lau,項目名稱:CSipSimple,代碼行數:41,代碼來源:MenuBuilder.java


注:本文中的android.view.KeyEvent.getKeyData方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。