本文整理汇总了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()");
}
}
示例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);
}
示例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);
}
示例4: dispatch
import android.view.KeyEvent; //导入方法依赖的package包/类
public boolean dispatch(KeyEvent event, Callback receiver, Object state, Object target) {
return event.dispatch(receiver);
}
示例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);
}