System.Windows.Forms.ToolStripManager.SetActiveToolStrip C# (CSharp) Method

SetActiveToolStrip() static private method

static private SetActiveToolStrip ( ToolStrip toolStrip, bool keyboard ) : void
toolStrip ToolStrip
keyboard bool
return void
		internal static void SetActiveToolStrip (ToolStrip toolStrip, bool keyboard)
		{
			if (Application.KeyboardCapture != null)
				Application.KeyboardCapture.KeyboardActive = false;
				
			if (toolStrip == null) {
				activated_by_keyboard = false;
				return;
			}
			
			activated_by_keyboard = keyboard;
				
			toolStrip.KeyboardActive = true;
		}
		

Usage Example

        public void Show(Point position, ToolStripDropDownDirection direction)
        {
            this.PerformLayout();

            Point show_point = CalculateShowPoint(position, direction, Size);

            if (this.Location != show_point)
            {
                this.Location = show_point;
            }

            // Prevents recursion
            if (Visible)
            {
                return;
            }

            CancelEventArgs e = new CancelEventArgs();

            this.OnOpening(e);

            if (e.Cancel)
            {
                return;
            }

            // The tracker lets us know when the form is clicked or loses focus
            ToolStripManager.AppClicked     += new EventHandler(ToolStripMenuTracker_AppClicked);
            ToolStripManager.AppFocusChange += new EventHandler(ToolStripMenuTracker_AppFocusChange);

            bool useNativeMenu = true;

            foreach (var item in this.Items)
            {
                useNativeMenu &= item is ToolStripMenuItem || item is ToolStripSeparator;
            }

            if (useNativeMenu)
            {
                currentMenu = ToNSMenu();
                ((MonoMenuDelegate)currentMenu.Delegate).BeforePopup();
                show_point = CalculateShowPoint(position, direction, new Size((int)currentMenu.Size.Width, (int)currentMenu.Size.Height));
                NSApplication.SharedApplication.BeginInvokeOnMainThread(delegate {
                    Size displaySize;
                    XplatUI.GetDisplaySize(out displaySize);
                    currentMenu.PopUpMenu(null, new CGPoint(show_point.X, displaySize.Height - show_point.Y), null);
                });
            }

            base.Show();

            ToolStripManager.SetActiveToolStrip(this, ToolStripManager.ActivatedByKeyboard);

            // Called from NSMenuDelegate for native menus
            if (!useNativeMenu)
            {
                this.OnOpened(EventArgs.Empty);
            }
        }
All Usage Examples Of System.Windows.Forms.ToolStripManager::SetActiveToolStrip