Ejemplo n.º 1
0
		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;
		}
Ejemplo n.º 2
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);
				}
			}
Ejemplo n.º 3
0
		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>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();
			}
		}
Ejemplo n.º 5
0
		public virtual bool dispatchKeyShortcutEvent(android.view.KeyEvent @event)
		{
			onUserInteraction();
			if (getWindow().superDispatchKeyShortcutEvent(@event))
			{
				return true;
			}
			return onKeyShortcut(@event.getKeyCode(), @event);
		}
Ejemplo n.º 6
0
		public override bool dispatchKeyEvent(android.view.KeyEvent @event)
		{
			int keyCode = @event.getKeyCode();
			if (keyCode == android.view.KeyEvent.KEYCODE_DPAD_CENTER || keyCode == android.view.KeyEvent
				.KEYCODE_ENTER)
			{
				removeAllCallbacks();
			}
			return base.dispatchKeyEvent(@event);
		}
Ejemplo n.º 7
0
		/// <summary>
		/// You can call this function yourself to have the scroll view perform
		/// scrolling from a key event, just as if the event had been dispatched to
		/// it by the view hierarchy.
		/// </summary>
		/// <remarks>
		/// You can call this function yourself to have the scroll view perform
		/// scrolling from a key event, just as if the event had been dispatched to
		/// it by the view hierarchy.
		/// </remarks>
		/// <param name="event">The key event to execute.</param>
		/// <returns>Return true if the event was handled, else false.</returns>
		public virtual bool executeKeyEvent(android.view.KeyEvent @event)
		{
			mTempRect.setEmpty();
			if (!canScroll())
			{
				if (isFocused())
				{
					android.view.View currentFocused = findFocus();
					if (currentFocused == this)
					{
						currentFocused = null;
					}
					android.view.View nextFocused = android.view.FocusFinder.getInstance().findNextFocus
						(this, currentFocused, android.view.View.FOCUS_RIGHT);
					return nextFocused != null && nextFocused != this && nextFocused.requestFocus(android.view.View
						.FOCUS_RIGHT);
				}
				return false;
			}
			bool handled = false;
			if (@event.getAction() == android.view.KeyEvent.ACTION_DOWN)
			{
				switch (@event.getKeyCode())
				{
					case android.view.KeyEvent.KEYCODE_DPAD_LEFT:
					{
						if ([email protected]())
						{
							handled = arrowScroll(android.view.View.FOCUS_LEFT);
						}
						else
						{
							handled = fullScroll(android.view.View.FOCUS_LEFT);
						}
						break;
					}

					case android.view.KeyEvent.KEYCODE_DPAD_RIGHT:
					{
						if ([email protected]())
						{
							handled = arrowScroll(android.view.View.FOCUS_RIGHT);
						}
						else
						{
							handled = fullScroll(android.view.View.FOCUS_RIGHT);
						}
						break;
					}

					case android.view.KeyEvent.KEYCODE_SPACE:
					{
						pageScroll(@event.isShiftPressed() ? android.view.View.FOCUS_LEFT : android.view.View
							.FOCUS_RIGHT);
						break;
					}
				}
			}
			return handled;
		}
Ejemplo n.º 8
0
		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;
		}
Ejemplo n.º 9
0
		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;
		}
Ejemplo n.º 10
0
		/// <hide></hide>
		public void dispatchKeyEvent(android.content.Context context, int seq, android.view.KeyEvent
			 key, [email protected] callback)
		{
			lock (mH)
			{
				if (mCurMethod == null)
				{
					try
					{
						callback.finishedEvent(seq, false);
					}
					catch (android.os.RemoteException)
					{
					}
					return;
				}
				if (key.getAction() == android.view.KeyEvent.ACTION_DOWN && key.getKeyCode() == android.view.KeyEvent
					.KEYCODE_SYM)
				{
					showInputMethodPicker();
					try
					{
						callback.finishedEvent(seq, true);
					}
					catch (android.os.RemoteException)
					{
					}
					return;
				}
				try
				{
					mCurMethod.dispatchKeyEvent(seq, key, callback);
				}
				catch (android.os.RemoteException e)
				{
					android.util.Log.w(TAG, "IME died: " + mCurId + " dropping: " + key, e);
					try
					{
						callback.finishedEvent(seq, false);
					}
					catch (android.os.RemoteException)
					{
					}
				}
			}
		}