protected internal override bool ProcessDialogKey(Keys keyData)
        {
            Keys keys = keyData & Keys.KeyCode;

            if (this.HasDropDownItems)
            {
                bool flag = !base.IsOnDropDown || base.IsOnOverflow;
                if (flag && (((keys == Keys.Down) || (keys == Keys.Up)) || ((keys == Keys.Enter) || (base.SupportsSpaceKey && (keys == Keys.Space)))))
                {
                    if (this.Enabled || base.DesignMode)
                    {
                        this.ShowDropDown();
                        this.DropDown.SelectNextToolStripItem(null, true);
                    }
                    return(true);
                }
                if (!flag)
                {
                    bool flag2 = (this.DropDownDirection & ToolStripDropDownDirection.AboveRight) == ToolStripDropDownDirection.AboveLeft;
                    if ((((keys == Keys.Enter) || (base.SupportsSpaceKey && (keys == Keys.Space))) || (flag2 && (keys == Keys.Left))) || (!flag2 && (keys == Keys.Right)))
                    {
                        if (this.Enabled || base.DesignMode)
                        {
                            this.ShowDropDown();
                            this.DropDown.SelectNextToolStripItem(null, true);
                        }
                        return(true);
                    }
                }
            }
            if (base.IsOnDropDown)
            {
                bool flag4 = (this.DropDownDirection & ToolStripDropDownDirection.AboveRight) == ToolStripDropDownDirection.AboveLeft;
                if ((flag4 && (keys == Keys.Right)) || (!flag4 && (keys == Keys.Left)))
                {
                    ToolStripDropDown currentParentDropDown = base.GetCurrentParentDropDown();
                    if ((currentParentDropDown != null) && !currentParentDropDown.IsFirstDropDown)
                    {
                        currentParentDropDown.SetCloseReason(ToolStripDropDownCloseReason.Keyboard);
                        currentParentDropDown.SelectPreviousToolStrip();
                        return(true);
                    }
                }
            }
            return(base.ProcessDialogKey(keyData));
        }
Exemple #2
0
        protected internal override bool ProcessDialogKey(Keys keyData)
        {
            Keys keyCode = (Keys)keyData & Keys.KeyCode;

            if (HasDropDownItems)
            {
                // VSWhidbey 478068: items on the overflow should have the same kind of keyboard handling as a toplevel
                bool isToplevel = (!IsOnDropDown || IsOnOverflow);


                if (isToplevel && (keyCode == Keys.Down || keyCode == Keys.Up || keyCode == Keys.Enter || (SupportsSpaceKey && keyCode == Keys.Space)))
                {
                    Debug.WriteLineIf(ToolStrip.SelectionDebug.TraceVerbose, "[SelectDBG ProcessDialogKey] open submenu from toplevel item");

                    if (Enabled || DesignMode)
                    {
                        // |__[ * File ]_____|  * is where you are.  Up or down arrow hit should expand menu
                        this.ShowDropDown();
                        if (!AccessibilityImprovements.UseLegacyToolTipDisplay)
                        {
                            KeyboardToolTipStateMachine.Instance.NotifyAboutLostFocus(this);
                        }
                        this.DropDown.SelectNextToolStripItem(null, true);
                    }// else eat the key
                    return(true);
                }
                else if (!isToplevel)
                {
                    // if we're on a DropDown - then cascade out.
                    bool menusCascadeRight = (((int)DropDownDirection & 0x0001) == 0);
                    bool forward           = ((keyCode == Keys.Enter) || (SupportsSpaceKey && keyCode == Keys.Space));
                    forward = (forward || (menusCascadeRight && keyCode == Keys.Left) || (!menusCascadeRight && keyCode == Keys.Right));


                    if (forward)
                    {
                        Debug.WriteLineIf(ToolStrip.SelectionDebug.TraceVerbose, "[SelectDBG ProcessDialogKey] open submenu from NON-toplevel item");

                        if (Enabled || DesignMode)
                        {
                            this.ShowDropDown();
                            if (!AccessibilityImprovements.UseLegacyToolTipDisplay)
                            {
                                KeyboardToolTipStateMachine.Instance.NotifyAboutLostFocus(this);
                            }
                            this.DropDown.SelectNextToolStripItem(null, true);
                        } // else eat the key
                        return(true);
                    }
                }
            }


            if (IsOnDropDown)
            {
                bool menusCascadeRight = (((int)DropDownDirection & 0x0001) == 0);
                bool backward          = ((menusCascadeRight && keyCode == Keys.Right) || (!menusCascadeRight && keyCode == Keys.Left));

                if (backward)
                {
                    Debug.WriteLineIf(ToolStrip.SelectionDebug.TraceVerbose, "[SelectDBG ProcessDialogKey] close submenu from NON-toplevel item");

                    // we're on a drop down but we're heading back up the chain.
                    // remember to select the item that displayed this dropdown.
                    ToolStripDropDown parent = GetCurrentParentDropDown();
                    if (parent != null && !parent.IsFirstDropDown)
                    {
                        // we're walking back up the dropdown chain.
                        parent.SetCloseReason(ToolStripDropDownCloseReason.Keyboard);
                        if (!AccessibilityImprovements.UseLegacyToolTipDisplay)
                        {
                            KeyboardToolTipStateMachine.Instance.NotifyAboutLostFocus(this);
                        }
                        parent.SelectPreviousToolStrip();
                        return(true);
                    }
                    // else if (parent.IsFirstDropDown)
                    //    the base handling (ToolStripDropDown.ProcessArrowKey) will perform auto-expansion of
                    //    the previous item in the menu.
                }
            }

            Debug.WriteLineIf(ToolStrip.SelectionDebug.TraceVerbose, "[SelectDBG ProcessDialogKey] ddi calling base");
            return(base.ProcessDialogKey(keyData));
        }
 internal static void CloseActiveDropDown(ToolStripDropDown activeToolStripDropDown, ToolStripDropDownCloseReason reason)
 {
     activeToolStripDropDown.SetCloseReason(reason);
     activeToolStripDropDown.Visible = false;
     if (GetActiveToolStrip() == null)
     {
         ExitMenuMode();
         if (activeToolStripDropDown.OwnerItem != null)
         {
             activeToolStripDropDown.OwnerItem.Unselect();
         }
     }
 }
Exemple #4
0
            internal static void CloseActiveDropDown(ToolStripDropDown activeToolStripDropDown, ToolStripDropDownCloseReason reason) {

                activeToolStripDropDown.SetCloseReason(reason);
                activeToolStripDropDown.Visible = false;

                // there's no more dropdowns left in the chain
                if (GetActiveToolStrip() == null) {
                    Debug.WriteLineIf(ToolStrip.SnapFocusDebug.TraceVerbose, "[ModalMenuFilter.CloseActiveDropDown] Calling exit because there are no more dropdowns left to activate.");
                    ExitMenuMode();

                    // make sure we roll selection off  the toplevel toolstrip.
                    if (activeToolStripDropDown.OwnerItem != null) {
                        activeToolStripDropDown.OwnerItem.Unselect();
                    }
                }

            }