* Application.cs: Give toolstrips a chance to process mnemonics.
* ToolStrip.cs, ToolStripDropDownButton.cs, ToolStripItem.cs,
ToolStripItemTextRenderEventArgs.cs, ToolStripLabel.cs,
ToolStripMenuItem.cs, ToolStripSplitButton.cs: Implement keyboard mnemonics.
svn path=/trunk/mcs/; revision=76528
m.HWnd = keyboard_capture.Handle;
- if (!keyboard_capture.PreProcessMessage (ref m)) {
+ if (!keyboard_capture.PreProcessMessage (ref m) && (m.Msg == (int)Msg.WM_KEYDOWN && !keyboard_capture.ProcessControlMnemonic ((char)m.WParam))) {
if (c == null || c.Parent == null || !(c.Parent is ToolStrip))
continue;
else
+2007-05-01 Jonathan Pobst <monkey@jpobst.com>
+
+ * Application.cs: Give toolstrips a chance to process mnemonics.
+ * ToolStrip.cs, ToolStripDropDownButton.cs, ToolStripItem.cs,
+ ToolStripItemTextRenderEventArgs.cs, ToolStripLabel.cs,
+ ToolStripMenuItem.cs, ToolStripSplitButton.cs: Implement keyboard mnemonics.
+
2007-05-01 Jackson Harper <jackson@ximian.com>
* TextBoxBase.cs: Better preferred height, FixedSingle gets the
protected override bool ProcessMnemonic (char charCode)
{
+ // If any item has an explicit mnemonic, it gets the message
+ foreach (ToolStripItem tsi in this.Items)
+ if (tsi.Enabled && tsi.Visible && Control.IsMnemonic (charCode, tsi.Text))
+ return tsi.ProcessMnemonic (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 && tsi.Text.Length > 0 && tsi.Text.ToUpper ().StartsWith (code))
+ return tsi.ProcessMnemonic (charCode);
+
return base.ProcessMnemonic (charCode);
}
Application.KeyboardCapture = this;
else if (Application.KeyboardCapture == this)
Application.KeyboardCapture = null;
+
+ // Redraw for mnemonic underlines
+ this.Refresh ();
}
}
}
ToolStripItem next_item = this.GetNextItem (start, forward ? ArrowDirection.Right : ArrowDirection.Left);
this.ChangeSelection (next_item);
-
+
+ if (next_item is ToolStripControlHost)
+ (next_item as ToolStripControlHost).Focus ();
+
return next_item;
}
return;
}
}
+
+ protected internal override bool ProcessMnemonic (char charCode)
+ {
+ if (!this.Selected)
+ this.Parent.ChangeSelection (this);
+
+ if (this.HasDropDownItems)
+ this.ShowDropDown ();
+ else
+ this.PerformClick ();
+
+ return true;
+ }
#endregion
}
}
return false;
}
+ // ProcessMnemonic will only be called if we are supposed to handle
+ // it. None of that fancy "thinking" needed!
protected internal virtual bool ProcessMnemonic (char charCode)
{
- return false;
+ this.PerformClick ();
+ return true;
}
protected internal virtual void SetBounds (Rectangle bounds)
break;
}
- this.text_format |= TextFormatFlags.HidePrefix;
+ if (Application.KeyboardCapture == null)
+ this.text_format |= TextFormatFlags.HidePrefix;
}
public ToolStripItemTextRenderEventArgs (Graphics g, ToolStripItem item, string text, Rectangle textRectangle, Color textColor, Font textFont, TextFormatFlags format)
this.Owner.Renderer.DrawItemText (new System.Windows.Forms.ToolStripItemTextRenderEventArgs (e.Graphics, this, this.Text, text_layout_rect, font_color, this.Font, this.TextAlign));
}
}
+
+ protected internal override bool ProcessMnemonic (char charCode)
+ {
+ this.Parent.SelectNextToolStripItem (this, true);
+ return true;
+ }
#endregion
}
}
return base.ProcessCmdKey (ref m, keyData);
}
+
+ protected internal override bool ProcessMnemonic (char charCode)
+ {
+ if (!this.Selected)
+ this.Parent.ChangeSelection (this);
+
+ if (this.HasDropDownItems) {
+ this.ShowDropDown ();
+ this.DropDown.SelectNextToolStripItem (null, true);
+ } else
+ this.PerformClick ();
+
+ return true;
+ }
protected internal override void SetBounds (Rectangle bounds)
{
return base.ProcessDialogKey (keyData);
}
+
+ protected internal override bool ProcessMnemonic (char charCode)
+ {
+ if (!this.Selected)
+ this.Parent.ChangeSelection (this);
+
+ if (this.HasDropDownItems)
+ this.ShowDropDown ();
+ else
+ this.PerformClick ();
+
+ return true;
+ }
#endregion
#region Public Events