当前位置: 首页>>代码示例>>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;未经允许,请勿转载。