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


Java KeyEvent.dispatch方法代碼示例

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


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

示例1: emulateShiftHeld

import android.view.KeyEvent; //導入方法依賴的package包/類
public void emulateShiftHeld() {
    try {

        KeyEvent shiftPressEvent = new KeyEvent(0, 0, KeyEvent.ACTION_DOWN,
                                                KeyEvent.KEYCODE_SHIFT_LEFT, 0, 0);
        shiftPressEvent.dispatch(this, null, null);
        Toast.makeText(getContext() , R.string.select_text_now, Toast.LENGTH_SHORT).show();
    } catch (Exception e) {
        Timber.e(e, "Exception in emulateShiftHeld()");
    }
}
 
開發者ID:philipwhiuk,項目名稱:q-mail,代碼行數:12,代碼來源:MessageWebView.java

示例2: dispatchKeyEvent

import android.view.KeyEvent; //導入方法依賴的package包/類
/**
 * Called to process key events.  You can override this to intercept all
 * key events before they are dispatched to the window.  Be sure to call
 * this implementation for key events that should be handled normally.
 *
 * @param event The key event.
 *
 * @return boolean Return true if this event was consumed.
 */
public boolean dispatchKeyEvent(KeyEvent event) {
    onUserInteraction();

    // Let action bars open menus in response to the menu key prioritized over
    // the window handling it
    final int keyCode = event.getKeyCode();
    if (keyCode == KeyEvent.KEYCODE_MENU &&
            mActionBar != null && mActionBar.onMenuKeyEvent(event)) {
        return true;
    } else if (event.isCtrlPressed() &&
            event.getUnicodeChar(event.getMetaState() & ~KeyEvent.META_CTRL_MASK) == '<') {
        // Capture the Control-< and send focus to the ActionBar
        final int action = event.getAction();
        if (action == KeyEvent.ACTION_DOWN) {
            final ActionBar actionBar = getActionBar();
            if (actionBar != null && actionBar.isShowing() && actionBar.requestFocus()) {
                mEatKeyUpEvent = true;
                return true;
            }
        } else if (action == KeyEvent.ACTION_UP && mEatKeyUpEvent) {
            mEatKeyUpEvent = false;
            return true;
        }
    }

    Window win = getWindow();
    if (win.superDispatchKeyEvent(event)) {
        return true;
    }
    View decor = mDecor;
    if (decor == null) decor = win.getDecorView();
    return event.dispatch(this, decor != null
            ? decor.getKeyDispatcherState() : null, this);
}
 
開發者ID:JessYanCoding,項目名稱:ProgressManager,代碼行數:44,代碼來源:a.java

示例3: dispatchKeyEvent

import android.view.KeyEvent; //導入方法依賴的package包/類
@Override
public boolean dispatchKeyEvent(KeyEvent event) {
    final View decor = mActivity.getWindow().getDecorView();
    return event.dispatch(mActivity, decor != null ? decor.getKeyDispatcherState() : null, mActivity);
}
 
開發者ID:alphater,項目名稱:garras,代碼行數:6,代碼來源:EventDispatcher.java

示例4: dispatch

import android.view.KeyEvent; //導入方法依賴的package包/類
public boolean dispatch(KeyEvent event, Callback receiver, Object state, Object target) {
    return event.dispatch(receiver);
}
 
開發者ID:JackChan1999,項目名稱:letv,代碼行數:4,代碼來源:KeyEventCompat.java

示例5: dispatch

import android.view.KeyEvent; //導入方法依賴的package包/類
public static boolean dispatch(KeyEvent event, Callback receiver, Object state, Object target) {
    return event.dispatch(receiver, (DispatcherState) state, target);
}
 
開發者ID:JackChan1999,項目名稱:boohee_v5.6,代碼行數:4,代碼來源:KeyEventCompatEclair.java


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