/// <summary> /// Process a dialog key in a manner appropriate for the view. /// </summary> /// <param name="keyData">Key data.</param> /// <returns>True if the key eaten; otherwise false.</returns> public override bool ProcessDialogKey(Keys keyData) { // Find out which modifier keys are being pressed bool shift = ((keyData & Keys.Shift) == Keys.Shift); bool control = ((keyData & Keys.Control) == Keys.Control); // Extract just the key and not modifier keys Keys keyCode = (keyData & Keys.KeyCode); // There must be a selected page before any action can occur if (Navigator.SelectedPage != null) { switch (keyCode) { case Keys.Up: case Keys.Down: case Keys.Left: case Keys.Right: // Using a navigation key when the selected button has focus if (HasFocus && _selectedButton.HasFocus) { // Shift focus to the currently selected page if (Navigator.SelectedPage != null) { // Remove focus from the selected button _selectedButton.HasFocus = false; // We should have a stack view for the page if (_pageStackLookup.ContainsKey(Navigator.SelectedPage)) { // Get the associated view element for the page ViewDrawNavCheckButtonBase checkButton = _pageStackLookup[Navigator.SelectedPage]; // Focus is in the check button checkButton.HasFocus = true; } // Need to repaint to show the change Navigator.PerformNeedPaint(true); return(true); } } break; case Keys.Space: case Keys.Enter: if (HasFocus) { // If the mini button does not have focus, give it focus if (!_selectedButton.HasFocus) { // Remove focus from the selected button _selectedButton.HasFocus = true; // Shift focus from the currently selected page if (Navigator.SelectedPage != null) { // We should have a stack view for the page if (_pageStackLookup.ContainsKey(Navigator.SelectedPage)) { // Get the associated view element for the page ViewDrawNavCheckButtonBase checkButton = _pageStackLookup[Navigator.SelectedPage]; // Focus is not longer on the check button checkButton.HasFocus = false; } } // Need to repaint to show the change Navigator.PerformNeedPaint(true); return(true); } else { // Mini button has focus, press the button _selectedButton.PerformClick(); } } break; } } // Let the base class perform additional testing return(base.ProcessDialogKey(keyData)); }