internal override bool ProcessArrowKey(Keys keyData) { switch (keyData) { case Keys.Down: case Keys.Tab: this.SelectNextToolStripItem(this.GetCurrentlySelectedItem(), true); return(true); case Keys.Up: case Keys.Shift | Keys.Tab: this.SelectNextToolStripItem(this.GetCurrentlySelectedItem(), false); return(true); case Keys.Right: this.GetTopLevelToolStrip().SelectNextToolStripItem(this.TopLevelOwnerItem, true); return(true); case Keys.Left: case Keys.Escape: this.Dismiss(ToolStripDropDownCloseReason.Keyboard); // ContextMenuStrip won't have a parent if (this.OwnerItem == null) { return(true); } ToolStrip parent_strip = this.OwnerItem.Parent; ToolStripManager.SetActiveToolStrip(parent_strip, true); if (parent_strip is MenuStrip && keyData == Keys.Left) { parent_strip.SelectNextToolStripItem(this.TopLevelOwnerItem, false); this.TopLevelOwnerItem.Invalidate(); } else if (parent_strip is MenuStrip && keyData == Keys.Escape) { (parent_strip as MenuStrip).MenuDroppedDown = false; this.TopLevelOwnerItem.Select(); } return(true); } return(false); }
private static bool ChangeSelection(ToolStrip start, ToolStrip toolStrip) { if ((toolStrip == null) || (start == null)) { return false; } if (start == toolStrip) { return false; } if (ModalMenuFilter.InMenuMode) { if (ModalMenuFilter.GetActiveToolStrip() == start) { ModalMenuFilter.RemoveActiveToolStrip(start); start.NotifySelectionChange(null); } ModalMenuFilter.SetActiveToolStrip(toolStrip); } else { toolStrip.FocusInternal(); } start.SnapFocusChange(toolStrip); toolStrip.SelectNextToolStripItem(null, toolStrip.RightToLeft != RightToLeft.Yes); return true; }
private static bool ChangeSelection(ToolStrip start, ToolStrip toolStrip) { if (toolStrip == null || start == null) { Debug.Assert(toolStrip != null, "passed in bogus toolstrip, why?"); Debug.Assert(start != null, "passed in bogus start, why?"); return false; } if (start == toolStrip) { return false; } if (ModalMenuFilter.InMenuMode) { if (ModalMenuFilter.GetActiveToolStrip() == start) { ModalMenuFilter.RemoveActiveToolStrip(start); start.NotifySelectionChange(null); } ModalMenuFilter.SetActiveToolStrip(toolStrip); } else { toolStrip.FocusInternal(); } // copy over the hwnd that we want to restore focus to on ESC start.SnapFocusChange(toolStrip); toolStrip.SelectNextToolStripItem(null, toolStrip.RightToLeft != RightToLeft.Yes); return true; }