+2007-05-24 Jonathan Pobst <monkey@jpobst.com>
+
+ * ContainerControl.cs: Don't check CanSelect before calling
+ ProcessMnemonic.
+ * ToolStrip.cs: Only do implicit mnemonics on MenuStrips. Don't
+ release a KeyboardActive on click if it's not ours.
+
2007-05-23 Andreia Gaita <avidigal@novell.com>
-* ColumnHeader.cs: Add TypeConverter
+ * ColumnHeader.cs: Add TypeConverter
2007-05-23 Everaldo Canuto <ecanuto@novell.com>
c = GetNextControl(c, true);
if (c != null) {
// This is stupid. I want to be able to call c.ProcessMnemonic directly
- if (c.CanSelect && c.ProcessControlMnemonic(charCode)) {
+ if (c.ProcessControlMnemonic(charCode)) {
return(true);
}
continue;
protected virtual void OnItemClicked (ToolStripItemClickedEventArgs e)
{
- ToolStripManager.SetActiveToolStrip (null);
+ if (this.KeyboardActive)
+ ToolStripManager.SetActiveToolStrip (null);
ToolStripItemClickedEventHandler eh = (ToolStripItemClickedEventHandler)(Events [ItemClickedEvent]);
if (eh != null)
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 && tsi.Text.Length > 0 && tsi.Text.ToUpper ().StartsWith (code))
- return tsi.ProcessMnemonic (charCode);
+ if (this is MenuStrip)
+ foreach (ToolStripItem tsi in this.Items)
+ if (tsi.Enabled && tsi.Visible && tsi.Text.Length > 0 && tsi.Text.ToUpper ().StartsWith (code))
+ return tsi.ProcessMnemonic (charCode);
return base.ProcessMnemonic (charCode);
}
return this;
}
- internal void HandleItemClick (ToolStripItem dismissingItem)
+ internal virtual void HandleItemClick (ToolStripItem dismissingItem)
{
this.GetTopLevelToolStrip ().Dismiss (ToolStripDropDownCloseReason.ItemClicked);
this.OnItemClicked (new ToolStripItemClickedEventArgs (dismissingItem));
+2007-05-24 Jonathan Pobst <monkey@jpobst.com>
+
+ * ContainerControlTest.cs: Test to show ProcessMnemonic is called
+ regardless of CanSelect.
+
2007-05-23 Jonathan Pobst <monkey@jpobst.com>
* TestHelper.cs: Remove reference to event_log from constructor.
form.Dispose();
}
+
+ [Test]
+ public void MnemonicCalledWhenCanSelectFalse ()
+ {
+ MyForm f = new MyForm ();
+ f.ShowInTaskbar = false;
+
+ MyControl c = new MyControl ();
+
+ f.Controls.Add (c);
+ f.Show ();
+
+ Assert.AreEqual (false, c.CanSelect, "A1");
+ f.PublicProcessMnemonic ('b');
+
+ Assert.AreEqual (true, c.mnemonic_called, "A2");
+ }
+
+ private class MyForm : Form
+ {
+ public bool PublicProcessMnemonic (char charCode)
+ {
+ return this.ProcessMnemonic (charCode);
+ }
+ }
+
+ private class MyControl : Control
+ {
+ public bool mnemonic_called;
+
+ public MyControl ()
+ {
+ SetStyle (ControlStyles.Selectable, false);
+ }
+
+ protected override bool ProcessMnemonic (char charCode)
+ {
+ mnemonic_called = true;
+ return base.ProcessMnemonic (charCode);
+ }
+ }
}
}