Java Code Examples for android.view.KeyEvent#dispatch()

The following examples show how to use android.view.KeyEvent#dispatch() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: Dialog.java    From android_9.0.0_r45 with Apache License 2.0 5 votes vote down vote up
/**
 * 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.
 */
@Override
public boolean dispatchKeyEvent(@NonNull KeyEvent event) {
    if ((mOnKeyListener != null) && (mOnKeyListener.onKey(this, event.getKeyCode(), event))) {
        return true;
    }
    if (mWindow.superDispatchKeyEvent(event)) {
        return true;
    }
    return event.dispatch(this, mDecor != null
            ? mDecor.getKeyDispatcherState() : null, this);
}
 
Example 2
Source File: AbstractInputMethodService.java    From android_9.0.0_r45 with Apache License 2.0 5 votes vote down vote up
/**
 * Take care of dispatching incoming key events to the appropriate
 * callbacks on the service, and tell the client when this is done.
 */
@Override
public void dispatchKeyEvent(int seq, KeyEvent event, EventCallback callback) {
    boolean handled = event.dispatch(AbstractInputMethodService.this,
            mDispatcherState, this);
    if (callback != null) {
        callback.finishedEvent(seq, handled);
    }
}
 
Example 3
Source File: KCWebView.java    From kerkee_android with GNU General Public License v3.0 5 votes vote down vote up
private boolean emulateShiftHeldForWebView(View view)
{
    try
    {
        KeyEvent shiftPressEvent = new KeyEvent(0, 0, KeyEvent.ACTION_DOWN, KeyEvent.KEYCODE_SHIFT_LEFT, 0, 0);
        shiftPressEvent.dispatch(view, null, null);
        return true;
    }
    catch (Exception e)
    {
        KCLog.e(e);
    }
    return false;
}
 
Example 4
Source File: Dialog.java    From PreferenceFragment with Apache License 2.0 5 votes vote down vote up
/**
 * 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) {
    if ((mOnKeyListener != null) && (mOnKeyListener.onKey(this, event.getKeyCode(), event))) {
        return true;
    }
    if (mWindow.superDispatchKeyEvent(event)) {
        return true;
    }
    return event
            .dispatch(this, mDecor != null ? mDecor.getKeyDispatcherState() : null, this);
}
 
Example 5
Source File: KeyEventCompatEclair.java    From V.FlyoutTest with MIT License 4 votes vote down vote up
public static boolean dispatch(KeyEvent event, KeyEvent.Callback receiver, Object state,
            Object target) {
    return event.dispatch(receiver, (KeyEvent.DispatcherState)state, target);
}
 
Example 6
Source File: TransportMediator.java    From android-recipes-app with Apache License 2.0 4 votes vote down vote up
@Override
public void handleKey(KeyEvent key) {
    key.dispatch(mKeyEventCallback);
}
 
Example 7
Source File: KeyEventCompat.java    From android-recipes-app with Apache License 2.0 4 votes vote down vote up
@Override
public boolean dispatch(KeyEvent event, KeyEvent.Callback receiver, Object state,
            Object target) {
    return event.dispatch(receiver);
}
 
Example 8
Source File: EventDispatcher.java    From FragmentMaster with Apache License 2.0 4 votes vote down vote up
@Override
public boolean dispatchKeyEvent(KeyEvent event) {
    View view = mMasterFragment.getView();
    return event.dispatch(mMasterFragment, view != null ? view.getKeyDispatcherState() : null, this);
}
 
Example 9
Source File: EventDispatcher.java    From FragmentMaster with Apache License 2.0 4 votes vote down vote up
@Override
public boolean dispatchKeyEvent(KeyEvent event) {
    final View decor = mActivity.getWindow().getDecorView();
    return event.dispatch(mActivity, decor != null ? decor.getKeyDispatcherState() : null, mActivity);
}
 
Example 10
Source File: TransportMediator.java    From adt-leanback-support with Apache License 2.0 4 votes vote down vote up
@Override
public void handleKey(KeyEvent key) {
    key.dispatch(mKeyEventCallback);
}
 
Example 11
Source File: KeyEventCompatEclair.java    From adt-leanback-support with Apache License 2.0 4 votes vote down vote up
public static boolean dispatch(KeyEvent event, KeyEvent.Callback receiver, Object state,
            Object target) {
    return event.dispatch(receiver, (KeyEvent.DispatcherState)state, target);
}
 
Example 12
Source File: KeyEventCompat.java    From adt-leanback-support with Apache License 2.0 4 votes vote down vote up
@Override
public boolean dispatch(KeyEvent event, KeyEvent.Callback receiver, Object state,
            Object target) {
    return event.dispatch(receiver);
}
 
Example 13
Source File: TransportMediator.java    From CodenameOne with GNU General Public License v2.0 4 votes vote down vote up
@Override
public void handleKey(KeyEvent key) {
    key.dispatch(mKeyEventCallback);
}
 
Example 14
Source File: TransportMediator.java    From V.FlyoutTest with MIT License 4 votes vote down vote up
@Override
public void handleKey(KeyEvent key) {
    key.dispatch(mKeyEventCallback);
}
 
Example 15
Source File: KeyEventCompat.java    From guideshow with MIT License 4 votes vote down vote up
@Override
public boolean dispatch(KeyEvent event, KeyEvent.Callback receiver, Object state,
            Object target) {
    return event.dispatch(receiver);
}
 
Example 16
Source File: a.java    From MiBandDecompiled with Apache License 2.0 4 votes vote down vote up
public void a(KeyEvent keyevent)
{
    keyevent.dispatch(a.i);
}
 
Example 17
Source File: u.java    From MiBandDecompiled with Apache License 2.0 4 votes vote down vote up
public static boolean a(KeyEvent keyevent, android.view.KeyEvent.Callback callback, Object obj, Object obj1)
{
    return keyevent.dispatch(callback, (android.view.KeyEvent.DispatcherState)obj, obj1);
}
 
Example 18
Source File: EcoGallery.java    From samples with Apache License 2.0 4 votes vote down vote up
@Override
public boolean dispatchKeyEvent(KeyEvent event) {
    // Gallery steals all key events
    return event.dispatch(this, null, null);
}
 
Example 19
Source File: KeyEventCompat.java    From letv with Apache License 2.0 4 votes vote down vote up
public boolean dispatch(KeyEvent event, Callback receiver, Object state, Object target) {
    return event.dispatch(receiver);
}
 
Example 20
Source File: KeyEventCompat.java    From V.FlyoutTest with MIT License 4 votes vote down vote up
@Override
public boolean dispatch(KeyEvent event, KeyEvent.Callback receiver, Object state,
            Object target) {
    return event.dispatch(receiver);
}