public virtual bool onKey(android.content.DialogInterface dialog, int keyCode, android.view.KeyEvent @event) { if (keyCode == android.view.KeyEvent.KEYCODE_MENU || keyCode == android.view.KeyEvent .KEYCODE_BACK) { if (@event.getAction() == android.view.KeyEvent.ACTION_DOWN && @event.getRepeatCount () == 0) { android.view.Window win = mDialog.getWindow(); if (win != null) { android.view.View decor = win.getDecorView(); if (decor != null) { android.view.KeyEvent.DispatcherState ds = decor.getKeyDispatcherState(); if (ds != null) { ds.startTracking(@event, this); return true; } } } } else { if (@event.getAction() == android.view.KeyEvent.ACTION_UP && [email protected]()) { android.view.Window win = mDialog.getWindow(); if (win != null) { android.view.View decor = win.getDecorView(); if (decor != null) { android.view.KeyEvent.DispatcherState ds = decor.getKeyDispatcherState(); if (ds != null && ds.isTracking(@event)) { mMenu.close(true); dialog.dismiss(); return true; } } } } } } // Menu shortcut matching return mMenu.performShortcut(keyCode, @event, 0); }
public override bool dispatchKeyEvent(android.view.KeyEvent @event) { if (@event.getKeyCode() == android.view.KeyEvent.KEYCODE_BACK) { if (this.getKeyDispatcherState() == null) { return base.dispatchKeyEvent(@event); } if (@event.getAction() == android.view.KeyEvent.ACTION_DOWN && @event.getRepeatCount () == 0) { android.view.KeyEvent.DispatcherState state = this.getKeyDispatcherState(); if (state != null) { state.startTracking(@event, this); } return true; } else { if (@event.getAction() == android.view.KeyEvent.ACTION_UP) { android.view.KeyEvent.DispatcherState state = this.getKeyDispatcherState(); if (state != null && state.isTracking(@event) && [email protected]()) { this._enclosing.dismiss(); return true; } } } return base.dispatchKeyEvent(@event); } else { return base.dispatchKeyEvent(@event); } }
/// <summary>Filter pre-IME key events.</summary> /// <remarks> /// Filter pre-IME key events. By forwarding /// <see cref="android.view.View.onKeyPreIme(int, android.view.KeyEvent)">android.view.View.onKeyPreIme(int, android.view.KeyEvent) /// </see> /// events to this function, views using ListPopupWindow can have it dismiss the popup /// when the back key is pressed. /// </remarks> /// <param name="keyCode">keyCode param passed to the host view's onKeyPreIme</param> /// <param name="event">event param passed to the host view's onKeyPreIme</param> /// <returns>true if the event was handled, false if it was ignored.</returns> /// <seealso cref="setModal(bool)">setModal(bool)</seealso> public virtual bool onKeyPreIme(int keyCode, android.view.KeyEvent @event) { if (keyCode == android.view.KeyEvent.KEYCODE_BACK && isShowing()) { // special case for the back key, we do not even try to send it // to the drop down list but instead, consume it immediately android.view.View anchorView = mDropDownAnchorView; if (@event.getAction() == android.view.KeyEvent.ACTION_DOWN && @event.getRepeatCount () == 0) { android.view.KeyEvent.DispatcherState state = anchorView.getKeyDispatcherState(); if (state != null) { state.startTracking(@event, this); } return true; } else { if (@event.getAction() == android.view.KeyEvent.ACTION_UP) { android.view.KeyEvent.DispatcherState state = anchorView.getKeyDispatcherState(); if (state != null) { state.handleUpEvent(@event); } if (@event.isTracking() && [email protected]()) { dismiss(); return true; } } } } return false; }
public override bool onKeyPreIme(int keyCode, android.view.KeyEvent @event) { if (keyCode == android.view.KeyEvent.KEYCODE_BACK) { // special case for the back key, we do not even try to send it // to the drop down list but instead, consume it immediately if (@event.getAction() == android.view.KeyEvent.ACTION_DOWN && @event.getRepeatCount () == 0) { android.view.KeyEvent.DispatcherState state = getKeyDispatcherState(); if (state != null) { state.startTracking(@event, this); } return true; } else { if (@event.getAction() == android.view.KeyEvent.ACTION_UP) { android.view.KeyEvent.DispatcherState state = getKeyDispatcherState(); if (state != null) { state.handleUpEvent(@event); } if (@event.isTracking() && [email protected]()) { mSearchView.clearFocus(); mSearchView.setImeVisibility(false); return true; } } } } return base.onKeyPreIme(keyCode, @event); }
private bool onContainerKey(android.view.KeyEvent @event) { int keyCode = @event.getKeyCode(); if (isInterestingKey(keyCode)) { if (keyCode == android.view.KeyEvent.KEYCODE_BACK) { if (@event.getAction() == android.view.KeyEvent.ACTION_DOWN && @event.getRepeatCount () == 0) { if (mOwnerView != null) { android.view.KeyEvent.DispatcherState ds = mOwnerView.getKeyDispatcherState(); if (ds != null) { ds.startTracking(@event, this); } } return true; } else { if (@event.getAction() == android.view.KeyEvent.ACTION_UP && @event.isTracking() && [email protected]()) { setVisible(false); return true; } } } else { dismissControlsDelayed(ZOOM_CONTROLS_TIMEOUT); } // Let the container handle the key return false; } else { android.view.ViewRootImpl viewRoot = getOwnerViewRootImpl(); if (viewRoot != null) { viewRoot.dispatchKey(@event); } // We gave the key to the owner, don't let the container handle this key return true; } }
public virtual bool onKeyUp(int keyCode, android.view.KeyEvent @event) { if (getApplicationInfo().targetSdkVersion >= android.os.Build.VERSION_CODES.ECLAIR) { if (keyCode == android.view.KeyEvent.KEYCODE_BACK && @event.isTracking() && !@event .isCanceled()) { onBackPressed(); return true; } } return false; }