2008-03-11 Jonathan Pobst <monkey@jpobst.com>
authorJonathan Pobst <monkey@jpobst.com>
Tue, 11 Mar 2008 19:20:13 +0000 (19:20 -0000)
committerJonathan Pobst <monkey@jpobst.com>
Tue, 11 Mar 2008 19:20:13 +0000 (19:20 -0000)
* ContainerControl.cs: We can't do MenuStrip implicit mnemonics
at the same time we do explicit ones, because we have to give all
other controls on the container a chance to handle explicit ones
first.  If no one has an explicit mnemonic, then we can let the
MenuStrip have a shot at implicit mnemonics.
* MenuStrip.cs: Create an implicit mnemonic function.
* ToolStrip.cs: When processing explicit mnemonics, don't do implicit
mnemonics for MenuStrips.
[Fixes bug #368493]

svn path=/trunk/mcs/; revision=97990

mcs/class/Managed.Windows.Forms/System.Windows.Forms/ChangeLog
mcs/class/Managed.Windows.Forms/System.Windows.Forms/ContainerControl.cs
mcs/class/Managed.Windows.Forms/System.Windows.Forms/MenuStrip.cs
mcs/class/Managed.Windows.Forms/System.Windows.Forms/ToolStrip.cs

index 983e20757a898cc303664ba99d335a7013bb339c..8e397ae0be61eff3c72f00c8a8acb699a5ab7c4f 100644 (file)
@@ -1,3 +1,15 @@
+2008-03-11  Jonathan Pobst  <monkey@jpobst.com>
+
+       * ContainerControl.cs: We can't do MenuStrip implicit mnemonics
+       at the same time we do explicit ones, because we have to give all
+       other controls on the container a chance to handle explicit ones
+       first.  If no one has an explicit mnemonic, then we can let the
+       MenuStrip have a shot at implicit mnemonics.
+       * MenuStrip.cs: Create an implicit mnemonic function.
+       * ToolStrip.cs: When processing explicit mnemonics, don't do implicit
+       mnemonics for MenuStrips.
+       [Fixes bug #368493]
+
 2008-03-11  Jonathan Pobst  <monkey@jpobst.com>
 
        * AxHost.cs, Binding.cs, DataGridView.cs, DataGridViewCell.cs,
index 701e9ae6f23df78d1abda85262e048a2caa0e23f..c4675a3df9bc3312a747ad7cf6894bf4792c2c85 100644 (file)
@@ -550,8 +550,16 @@ namespace System.Windows.Forms {
                        wrapped = false;
                        c = active_control;
 
+#if NET_2_0
+                       System.Collections.Generic.List<MenuStrip> strips = new System.Collections.Generic.List<MenuStrip> ();
+#endif
+
                        do {
                                c = GetNextControl(c, true);
+#if NET_2_0
+                               if (c is MenuStrip)
+                                       strips.Add ((MenuStrip)c);
+#endif
                                if (c != null) {
                                        // This is stupid. I want to be able to call c.ProcessMnemonic directly
                                        if (c.ProcessControlMnemonic(charCode)) {
@@ -566,6 +574,14 @@ namespace System.Windows.Forms {
                                }
                        } while (c != active_control);
 
+#if NET_2_0
+                       // No one has an explicit mnemonic for this key.
+                       // Let MenuStrips have a chance at implicit mnemonics.
+                       foreach (MenuStrip ms in strips)
+                               if (ms.ProcessImplicitMnemonic (charCode))
+                                       return true;
+#endif
+
                        return false;
                }
 
index ecc324db7c892d0f0d91e3f986fd632c08ad6ead..7bd77a15cfa9fd8df888dcde6ff55bee58412d5a 100644 (file)
@@ -306,6 +306,18 @@ namespace System.Windows.Forms
                        
                        return false;
                }
+
+               internal bool ProcessImplicitMnemonic (char charCode)
+               {
+                       string code = Char.ToUpper (charCode).ToString ();
+                       
+                       // If any item's text starts with our letter, it gets the message
+                       foreach (ToolStripItem tsi in this.Items)
+                               if (tsi.Enabled && tsi.Visible && !string.IsNullOrEmpty (tsi.Text) && tsi.Text.ToUpper ().StartsWith (code))
+                                       return tsi.ProcessMnemonic (charCode);
+                                       
+                       return false;
+               }
                
                private void ReorderMdiMenu ()
                {
index 6f0fa20f54ea579c77afd67246e322509f312b3e..60b7d810618d9f66c18df836b7f89ea63ee48b2f 100644 (file)
@@ -1125,7 +1125,7 @@ namespace System.Windows.Forms
                        string code = Char.ToUpper (charCode).ToString ();
                        
                        // If any item's text starts with our letter, it gets the message
-                       if (this is MenuStrip || this is ToolStripDropDownMenu)
+                       if (this is ToolStripDropDownMenu)
                                foreach (ToolStripItem tsi in this.Items)
                                        if (tsi.Enabled && tsi.Visible && !string.IsNullOrEmpty (tsi.Text) && tsi.Text.ToUpper ().StartsWith (code))
                                                return tsi.ProcessMnemonic (charCode);