Example #1
0
		/// <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;
		}
		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;
			}
		}
Example #3
0
			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);
			}
Example #4
0
		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() && [email protected]
					.isCanceled())
				{
					onBackPressed();
					return true;
				}
			}
			return false;
		}