SidebarLibrary.Menus.MenuControl.OnKeyDown C# (CSharp) Method

OnKeyDown() protected method

protected OnKeyDown ( KeyEventArgs e ) : void
e System.Windows.Forms.KeyEventArgs
return void
		protected override void OnKeyDown(KeyEventArgs e)
		{
			switch(e.KeyCode)
			{
			case Keys.Escape:
				// Is an item being tracked
				if (_trackItem != -1)
				{
					// Is that item also selected
					if (_selected)
					{
						// Is it also showing a submenu
						if (_popupMenu == null)
						{
							// Deselect the item
							_selected = false;
							_drawUpwards = false;

							// Repaint the item
							DrawCommand(_trackItem, true);

							ReturnTheFocus();

							// Key has been processed
							e.Handled = true;
						}
						else
						{
							// The popup menu will swallow the escape
							_ignoreEscapeUp = true;
						}
					}
				}
				break;
			case Keys.Left:
				if (_direction == Direction.Horizontal)
					ProcessMoveLeft(false);

				if (_selected)
					_ignoreMouseMove = true;
				break;
			case Keys.Right:
				if (_direction == Direction.Horizontal)
					ProcessMoveRight(false);
				else
					ProcessMoveDown();

				if (_selected)
					_ignoreMouseMove = true;
				break;
			case Keys.Down:
				if (_direction == Direction.Horizontal)
					ProcessMoveDown();
				else
					ProcessMoveRight(false);
				break;
			case Keys.Up:
				if (_direction == Direction.Vertical)
					ProcessMoveLeft(false);

				break;
			}

			base.OnKeyDown(e);
		}