private void KeyDownPopupMinimized(VisualPopupMinimized popupMinimized, KeyEventArgs e) { switch (e.KeyData) { case Keys.Tab | Keys.Shift: case Keys.Left: popupMinimized.SetPreviousFocusItem(); break; case Keys.Tab: case Keys.Right: popupMinimized.SetNextFocusItem(); break; } }
private void KeyDownPopupMinimized(VisualPopupMinimized popupMinimized, KeyEventArgs e) { switch (e.KeyData) { case Keys.Tab | Keys.Shift: case Keys.Left: popupMinimized.SetPreviousFocusItem(); break; case Keys.Tab: case Keys.Right: popupMinimized.SetNextFocusItem(); break; case Keys.Space: case Keys.Enter: // Exit keyboard mode when you click the button spec Ribbon.KillKeyboardMode(); // Generate a click event OnClick(new MouseEventArgs(MouseButtons.Left, 1, 0, 0, 0)); break; } }
/// <summary> /// Key has been pressed down. /// </summary> /// <param name="c">Reference to the source control instance.</param> /// <param name="e">A KeyEventArgs that contains the event data.</param> public void KeyDown(Control c, KeyEventArgs e) { ViewBase newView = null; Keys keyData = e.KeyData; // When there is no selected tab then tab and shift+tab become right and left if (_ribbon.SelectedTab == null) { if (keyData == Keys.Tab) { keyData = Keys.Right; } if (keyData == (Keys.Tab | Keys.Shift)) { keyData = Keys.Left; } } switch (keyData) { case Keys.Right: // Get the next visible tab page newView = (_target.ViewLayoutRibbonTabs.GetViewForNextRibbonTab(_target.RibbonTab) ?? (ViewBase)_ribbon.TabsArea.ButtonSpecManager.GetFirstVisibleViewButton(PaletteRelativeEdgeAlign.Far)) ?? _ribbon.TabsArea.ButtonSpecManager.GetFirstVisibleViewButton(PaletteRelativeEdgeAlign.Inherit); // Move across to any far defined buttons // Move across to any inherit defined buttons // Rotate around to application button if (newView == null) { if (_ribbon.TabsArea.LayoutAppButton.Visible) { newView = _ribbon.TabsArea.LayoutAppButton.AppButton; } else if (_ribbon.TabsArea.LayoutAppTab.Visible) { newView = _ribbon.TabsArea.LayoutAppTab.AppTab; } } break; case Keys.Left: // Get the previous visible tab page newView = (_target.ViewLayoutRibbonTabs.GetViewForPreviousRibbonTab(_target.RibbonTab) ?? (ViewBase)_ribbon.TabsArea.ButtonSpecManager.GetFirstVisibleViewButton(PaletteRelativeEdgeAlign.Near)) ?? _ribbon.GetLastQATView(); // Move across to any near defined buttons // Get the last qat button // Rotate around to application button if (newView == null) { if (_ribbon.TabsArea.LayoutAppButton.Visible) { newView = _ribbon.TabsArea.LayoutAppButton.AppButton; } else if (_ribbon.TabsArea.LayoutAppTab.Visible) { newView = _ribbon.TabsArea.LayoutAppTab.AppTab; } } break; case Keys.Tab | Keys.Shift: // Move across to any near defined buttons newView = _ribbon.TabsArea.ButtonSpecManager.GetFirstVisibleViewButton(PaletteRelativeEdgeAlign.Near) ?? _ribbon.GetLastQATView(); // Get the last qat button // Rotate around to application button if (newView == null) { if (_ribbon.TabsArea.LayoutAppButton.Visible) { newView = _ribbon.TabsArea.LayoutAppButton.AppButton; } else if (_ribbon.TabsArea.LayoutAppTab.Visible) { newView = _ribbon.TabsArea.LayoutAppTab.AppTab; } } break; case Keys.Down: // Get the first focus item for the currently selected page newView = _ribbon.GroupsArea.ViewGroups.GetFirstFocusItem(); break; case Keys.Tab: // Get the first focus item for the currently selected page newView = (_ribbon.GroupsArea.ViewGroups.GetFirstFocusItem() ?? _ribbon.TabsArea.ButtonSpecManager.GetFirstVisibleViewButton(PaletteRelativeEdgeAlign.Near)) ?? _ribbon.GetLastQATView(); // Move across to any near defined buttons // Get the last qat button // Rotate around to application button if (newView == null) { if (_ribbon.TabsArea.LayoutAppButton.Visible) { newView = _ribbon.TabsArea.LayoutAppButton.AppButton; } else if (_ribbon.TabsArea.LayoutAppTab.Visible) { newView = _ribbon.TabsArea.LayoutAppTab.AppTab; } } break; case Keys.Enter: case Keys.Space: // When minimize, pressing enter will select the tab and pop it up if ((_ribbon.RealMinimizedMode) && (_ribbon.SelectedTab != _target.RibbonTab)) { // Select the tab will automatically create a popup for it _ribbon.SelectedTab = _target.RibbonTab; // Get access to the popup for the group if ((VisualPopupManager.Singleton.CurrentPopup != null) && (VisualPopupManager.Singleton.CurrentPopup is VisualPopupMinimized)) { // Cast to correct type VisualPopupMinimized popupMinimized = (VisualPopupMinimized)VisualPopupManager.Singleton.CurrentPopup; popupMinimized.SetFirstFocusItem(); } } break; } // If we have a new view to focus and it is not ourself... if ((newView != null) && (newView != _target)) { // If the new view is a tab then select that tab if (!_ribbon.RealMinimizedMode && (newView is ViewDrawRibbonTab tab)) { _ribbon.SelectedTab = tab.RibbonTab; } // Finally we switch focus to new view _ribbon.FocusView = newView; } }