Beispiel #1
0
		internal virtual [email protected] findItemWithShortcutForKey
			(int keyCode, android.view.KeyEvent @event)
		{
			// Get all items that can be associated directly or indirectly with the keyCode
			java.util.ArrayList<*****@*****.**> items = mTempShortcutItemList;
			items.clear();
			findItemsWithShortcutForKey(items, keyCode, @event);
			if (items.isEmpty())
			{
				return null;
			}
			int metaState = @event.getMetaState();
			android.view.KeyCharacterMap.KeyData possibleChars = new android.view.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
			int size_1 = items.size();
			if (size_1 == 1)
			{
				return items.get(0);
			}
			bool 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_1; i++)
				{
					[email protected] item = items.get(i);
					char shortcutChar = qwerty ? item.getAlphabeticShortcut() : item.getNumericShortcut
						();
					if ((shortcutChar == possibleChars.meta[0] && (metaState & android.view.KeyEvent.
						META_ALT_ON) == 0) || (shortcutChar == possibleChars.meta[2] && (metaState & android.view.KeyEvent
						.META_ALT_ON) != 0) || (qwerty && shortcutChar == '\b' && keyCode == android.view.KeyEvent
						.KEYCODE_DEL))
					{
						return item;
					}
				}
			}
			return null;
		}
Beispiel #2
0
		internal virtual void findItemsWithShortcutForKey(java.util.List<*****@*****.**
			> items, int keyCode, android.view.KeyEvent @event)
		{
			bool qwerty = isQwertyMode();
			int metaState = @event.getMetaState();
			android.view.KeyCharacterMap.KeyData possibleChars = new android.view.KeyCharacterMap
				.KeyData();
			// Get the chars associated with the keyCode (i.e using any chording combo)
			bool isKeyCodeMapped = @event.getKeyData(possibleChars);
			// The delete key is not mapped to '\b' so we treat it specially
			if (!isKeyCodeMapped && (keyCode != android.view.KeyEvent.KEYCODE_DEL))
			{
				return;
			}
			// Look for an item whose shortcut is this key.
			int N = mItems.size();
			{
				for (int i = 0; i < N; i++)
				{
					[email protected] item = mItems.get(i);
					if (item.hasSubMenu())
					{
						(([email protected])item.getSubMenu()).findItemsWithShortcutForKey
							(items, keyCode, @event);
					}
					char shortcutChar = qwerty ? item.getAlphabeticShortcut() : item.getNumericShortcut
						();
					if (((metaState & (android.view.KeyEvent.META_SHIFT_ON | android.view.KeyEvent.META_SYM_ON
						)) == 0) && (shortcutChar != 0) && (shortcutChar == possibleChars.meta[0] || shortcutChar
						 == possibleChars.meta[2] || (qwerty && shortcutChar == '\b' && keyCode == android.view.KeyEvent
						.KEYCODE_DEL)) && item.isEnabled())
					{
						items.add(item);
					}
				}
			}
		}