Cause MenuDeactivate event to be delivered when appropriate
authorPeter Collingbourne <peter@pcc.me.uk>
Mon, 2 Apr 2012 04:28:58 +0000 (05:28 +0100)
committerPeter Collingbourne <peter@pcc.me.uk>
Mon, 2 Apr 2012 04:52:21 +0000 (05:52 +0100)
This is achieved by moving the FireMenuDeactivate call to
MenuStrip.Dismiss and causing it to be called in a couple of places
where it ought to be.

mcs/class/Managed.Windows.Forms/System.Windows.Forms/MenuStrip.cs
mcs/class/Managed.Windows.Forms/System.Windows.Forms/ToolStrip.cs
mcs/class/Managed.Windows.Forms/System.Windows.Forms/ToolStripMenuItem.cs

index 8cad840c4eef4f16614d9aad46d2f59a2cf8512d..8470f2987b7dca8bf4c2793954444eb12f69eeed 100644 (file)
@@ -173,6 +173,8 @@ namespace System.Windows.Forms
                        this.MenuDroppedDown = false;
                        
                        base.Dismiss (reason);
+
+                       this.FireMenuDeactivate ();
                }
                
                internal void FireMenuActivate ()
index 350fa056b8103e264b7cc6a468b8facf9848468b..35c7f80711b5c072804132f74ec43d596f696295 100644 (file)
@@ -892,7 +892,7 @@ namespace System.Windows.Forms
                                if (this is MenuStrip && mouse_currently_over is ToolStripMenuItem && !(mouse_currently_over as ToolStripMenuItem).HasDropDownItems)
                                        return;
                        } else {
-                               this.HideMenus (true, ToolStripDropDownCloseReason.AppClicked);
+                               this.Dismiss (ToolStripDropDownCloseReason.AppClicked);
                        }
                        
                        if (this is MenuStrip)
@@ -1501,17 +1501,6 @@ namespace System.Windows.Forms
                        this.GetTopLevelToolStrip ().Dismiss (ToolStripDropDownCloseReason.ItemClicked);
                }
                
-               internal void HideMenus (bool release, ToolStripDropDownCloseReason reason)
-               {
-                       if (this is MenuStrip && release && menu_selected)
-                               (this as MenuStrip).FireMenuDeactivate ();
-                               
-                       if (release)
-                               menu_selected = false;
-                               
-                       NotifySelectedChanged (null);
-               }
-
                internal void NotifySelectedChanged (ToolStripItem tsi)
                {
                        foreach (ToolStripItem tsi2 in this.DisplayedItems)
index da16b149adca32f86790894574a3db73ba4d3548..4df33979088fc1fc0fcd884ff0a01ec3403f49a5 100644 (file)
@@ -315,12 +315,9 @@ namespace System.Windows.Forms
                protected override void OnMouseUp (MouseEventArgs e)
                {
                        if (this.close_on_mouse_release) {
-                               this.DropDown.Dismiss (ToolStripDropDownCloseReason.ItemClicked);
+                               this.Parent.Dismiss (ToolStripDropDownCloseReason.ItemClicked);
                                this.Invalidate ();
                                this.close_on_mouse_release = false;
-                               
-                               if (!this.IsOnDropDown && this.Parent is MenuStrip)
-                                       (this.Parent as MenuStrip).MenuDroppedDown = false;
                        }
                                
                        if (!this.HasDropDownItems && Enabled)