Example usage for android.view Menu performShortcut

List of usage examples for android.view Menu performShortcut

Introduction

In this page you can find the example usage for android.view Menu performShortcut.

Prototype

public boolean performShortcut(int keyCode, KeyEvent event, int flags);

Source Link

Document

Execute the menu item action associated with the given shortcut character.

Usage

From source file:android.support.v7.internal.app.ToolbarActionBar.java

@Override
public boolean onKeyShortcut(int keyCode, KeyEvent ev) {
    Menu menu = getMenu();
    return menu != null ? menu.performShortcut(keyCode, ev, 0) : false;
}

From source file:android.support.v7.app.ToolbarActionBar.java

@Override
public boolean onKeyShortcut(int keyCode, KeyEvent ev) {
    Menu menu = getMenu();
    if (menu != null) {
        final KeyCharacterMap kmap = KeyCharacterMap
                .load(ev != null ? ev.getDeviceId() : KeyCharacterMap.VIRTUAL_KEYBOARD);
        menu.setQwertyMode(kmap.getKeyboardType() != KeyCharacterMap.NUMERIC);
        menu.performShortcut(keyCode, ev, 0);
    }//from  ww w .  java  2  s.  c o  m
    // This action bar always returns true for handling keyboard shortcuts.
    // This will block the window from preparing a temporary panel to handle
    // keyboard shortcuts.
    return true;
}