public virtual bool onKeyOther(android.view.View view, android.text.Editable content , android.view.KeyEvent @event) { if (@event.getAction() != android.view.KeyEvent.ACTION_MULTIPLE || @event.getKeyCode () != android.view.KeyEvent.KEYCODE_UNKNOWN) { // Not something we are interested in. return(false); } int selectionStart = android.text.Selection.getSelectionStart(content); int selectionEnd = android.text.Selection.getSelectionEnd(content); if (selectionEnd < selectionStart) { int temp = selectionEnd; selectionEnd = selectionStart; selectionStart = temp; } java.lang.CharSequence text = java.lang.CharSequenceProxy.Wrap(@event.getCharacters ()); if (text == null) { return(false); } content.replace(selectionStart, selectionEnd, text); return(true); }
public override bool dispatchKeyEvent(android.view.KeyEvent @event) { if (@event.getKeyCode() == android.view.KeyEvent.KEYCODE_MENU) { if (@event.getAction() == android.view.KeyEvent.ACTION_DOWN && @event.getRepeatCount () == 0) { removeCallbacks(this); postDelayed(this, android.view.ViewConfiguration.getLongPressTimeout()); } else { if (@event.getAction() == android.view.KeyEvent.ACTION_UP) { if (mMenuBeingLongpressed) { // It was in cycle mode, so reset it (will also remove us // from being called back) setCycleShortcutCaptionMode(false); return(true); } else { // Just remove us from being called back removeCallbacks(this); } } } } // Fall through to normal processing too return(base.dispatchKeyEvent(@event)); }
public virtual bool onKeyOther(android.widget.TextView widget, android.text.Spannable text, android.view.KeyEvent @event) { int movementMetaState = getMovementMetaState(text, @event); int keyCode = @event.getKeyCode(); if (keyCode != android.view.KeyEvent.KEYCODE_UNKNOWN && @event.getAction() == android.view.KeyEvent .ACTION_MULTIPLE) { int repeat = @event.getRepeatCount(); bool handled = false; { for (int i = 0; i < repeat; i++) { if (!handleMovementKey(widget, text, keyCode, movementMetaState, @event)) { break; } handled = true; } } if (handled) { android.text.method.MetaKeyKeyListener.adjustMetaAfterKeypress(text); android.text.method.MetaKeyKeyListener.resetLockedMeta(text); } return handled; } return false; }
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); } }
/// <summary> /// Notifies the verifier that a given event was unhandled and the rest of the /// trace for the event should be ignored. /// </summary> /// <remarks> /// Notifies the verifier that a given event was unhandled and the rest of the /// trace for the event should be ignored. /// This method should only be called if the event was previously checked by /// the consistency verifier using /// <see cref="onInputEvent(InputEvent, int)">onInputEvent(InputEvent, int)</see> /// and other methods. /// </remarks> /// <param name="event">The event.</param> /// <param name="nestingLevel"> /// The nesting level: 0 if called from the base class, /// or 1 from a subclass. If the event was already checked by this consistency verifier /// at a higher nesting level, it will not be checked again. Used to handle the situation /// where a subclass dispatching method delegates to its superclass's dispatching method /// and both dispatching methods call into the consistency verifier. /// </param> public void onUnhandledEvent(android.view.InputEvent @event, int nestingLevel) { if (nestingLevel != mLastNestingLevel) { return; } if (mRecentEventsUnhandled != null) { mRecentEventsUnhandled[mMostRecentEventIndex] = true; } if (@event is android.view.KeyEvent) { android.view.KeyEvent keyEvent = (android.view.KeyEvent)@event; int deviceId = keyEvent.getDeviceId(); int source = keyEvent.getSource(); int keyCode = keyEvent.getKeyCode(); android.view.InputEventConsistencyVerifier.KeyState state = findKeyState(deviceId , source, keyCode, false); if (state != null) { state.unhandled = true; } } else { android.view.MotionEvent motionEvent = (android.view.MotionEvent)@event; if (motionEvent.isTouchEvent()) { mTouchEventStreamUnhandled = true; } else { if ((motionEvent.getSource() & android.view.InputDevice.SOURCE_CLASS_TRACKBALL) != 0) { if (mTrackballDown) { mTrackballUnhandled = true; } } } } }
public override bool dispatchKeyEvent(android.view.KeyEvent @event) { bool handled = base.dispatchKeyEvent(@event); // unhandled key ups change focus to tab indicator for embedded activities // when there is nothing that will take focus from default focus searching if (!handled && (@event.getAction() == android.view.KeyEvent.ACTION_DOWN) && (@event .getKeyCode() == android.view.KeyEvent.KEYCODE_DPAD_UP) && (mCurrentView != null ) && (mCurrentView.isRootNamespace()) && (mCurrentView.hasFocus()) && (mCurrentView .findFocus().focusSearch(android.view.View.FOCUS_UP) == null)) { mTabWidget.getChildTabViewAt(mCurrentTab).requestFocus(); playSoundEffect(android.view.SoundEffectConstants.NAVIGATION_UP); return(true); } return(handled); }
/// <summary>Checks a key event.</summary> /// <remarks>Checks a key event.</remarks> /// <param name="event">The event.</param> /// <param name="nestingLevel"> /// The nesting level: 0 if called from the base class, /// or 1 from a subclass. If the event was already checked by this consistency verifier /// at a higher nesting level, it will not be checked again. Used to handle the situation /// where a subclass dispatching method delegates to its superclass's dispatching method /// and both dispatching methods call into the consistency verifier. /// </param> public void onKeyEvent(android.view.KeyEvent @event, int nestingLevel) { if (!startEvent(@event, nestingLevel, EVENT_TYPE_KEY)) { return; } try { ensureMetaStateIsNormalized(@event.getMetaState()); int action = @event.getAction(); int deviceId = @event.getDeviceId(); int source = @event.getSource(); int keyCode = @event.getKeyCode(); switch (action) { case android.view.KeyEvent.ACTION_DOWN: { android.view.InputEventConsistencyVerifier.KeyState state = findKeyState(deviceId , source, keyCode, false); if (state != null) { // If the key is already down, ensure it is a repeat. // We don't perform this check when processing raw device input // because the input dispatcher itself is responsible for setting // the key repeat count before it delivers input events. if (state.unhandled) { state.unhandled = false; } else { if ((mFlags & FLAG_RAW_DEVICE_INPUT) == 0 && @event.getRepeatCount() == 0) { problem("ACTION_DOWN but key is already down and this event " + "is not a key repeat." ); } } } else { addKeyState(deviceId, source, keyCode); } break; } case android.view.KeyEvent.ACTION_UP: { android.view.InputEventConsistencyVerifier.KeyState state = findKeyState(deviceId , source, keyCode, true); if (state == null) { problem("ACTION_UP but key was not down."); } else { state.recycle(); } break; } case android.view.KeyEvent.ACTION_MULTIPLE: { break; } default: { problem("Invalid action " + android.view.KeyEvent.actionToString(action) + " for key event." ); break; } } } finally { finishEvent(); } }