Author: jpobst
Date: 2007-04-30 13:43:32 -0400 (Mon, 30 Apr 2007)
New Revision: 76504
Modified:
trunk/mcs/class/Managed.Windows.Forms/System.Windows.Forms/Application.cs
trunk/mcs/class/Managed.Windows.Forms/System.Windows.Forms/ChangeLog
trunk/mcs/class/Managed.Windows.Forms/System.Windows.Forms/ToolStrip.cs
trunk/mcs/class/Managed.Windows.Forms/System.Windows.Forms/ToolStripControlHost.cs
trunk/mcs/class/Managed.Windows.Forms/System.Windows.Forms/ToolStripDropDown.cs
trunk/mcs/class/Managed.Windows.Forms/System.Windows.Forms/ToolStripManager.cs
Log:
2007-04-30 Jonathan Pobst <[EMAIL PROTECTED]>
* Application.cs: When using the toolstrip shortcut mechanism, allow the
message to pass through to a regular control if it hosted by a
toolstrip.
* ToolStrip.cs, ToolStripControlHost.cs, ToolStripDropDown.cs,
ToolStripManager.cs: Enable keyboard navigation for ToolStrips.
Modified:
trunk/mcs/class/Managed.Windows.Forms/System.Windows.Forms/Application.cs
===================================================================
--- trunk/mcs/class/Managed.Windows.Forms/System.Windows.Forms/Application.cs
2007-04-30 16:11:26 UTC (rev 76503)
+++ trunk/mcs/class/Managed.Windows.Forms/System.Windows.Forms/Application.cs
2007-04-30 17:43:32 UTC (rev 76504)
@@ -662,6 +662,9 @@
Message m;
m = Message.Create(msg.hwnd,
(int)msg.message, msg.wParam, msg.lParam);
+ Control c;
+ c = Control.FromHandle(msg.hwnd);
+
#if NET_2_0
// If we have a control with keyboard
capture (usually a *Strip)
// give it the message, and then drop
the message
@@ -674,14 +677,17 @@
}
m.HWnd =
keyboard_capture.Handle;
-
keyboard_capture.PreProcessMessage (ref m);
- continue;
+
+ if
(!keyboard_capture.PreProcessMessage (ref m)) {
+ if (c == null ||
c.Parent == null || !(c.Parent is ToolStrip))
+ continue;
+ else
+ m.HWnd =
msg.hwnd;
+ } else
+ continue;
}
#endif
- Control c;
-
- c = Control.FromHandle(msg.hwnd);
if ((c != null) &&
!c.PreProcessMessage(ref m)) {
goto default;
}
Modified: trunk/mcs/class/Managed.Windows.Forms/System.Windows.Forms/ChangeLog
===================================================================
--- trunk/mcs/class/Managed.Windows.Forms/System.Windows.Forms/ChangeLog
2007-04-30 16:11:26 UTC (rev 76503)
+++ trunk/mcs/class/Managed.Windows.Forms/System.Windows.Forms/ChangeLog
2007-04-30 17:43:32 UTC (rev 76504)
@@ -1,5 +1,12 @@
2007-04-30 Jonathan Pobst <[EMAIL PROTECTED]>
+ * Application.cs: When using the toolstrip shortcut mechanism, allow the
+ message to pass through to a regular control if it hosted by a
toolstrip.
+ * ToolStrip.cs, ToolStripControlHost.cs, ToolStripDropDown.cs,
+ ToolStripManager.cs: Enable keyboard navigation for ToolStrips.
+
+2007-04-30 Jonathan Pobst <[EMAIL PROTECTED]>
+
* TextRenderer.cs: Use the flags argument when using the MeasureString
fallback algorithm.
Modified:
trunk/mcs/class/Managed.Windows.Forms/System.Windows.Forms/ToolStrip.cs
===================================================================
--- trunk/mcs/class/Managed.Windows.Forms/System.Windows.Forms/ToolStrip.cs
2007-04-30 16:11:26 UTC (rev 76503)
+++ trunk/mcs/class/Managed.Windows.Forms/System.Windows.Forms/ToolStrip.cs
2007-04-30 17:43:32 UTC (rev 76504)
@@ -984,6 +984,9 @@
protected override bool ProcessDialogKey (Keys keyData)
{
+ if (!this.KeyboardActive)
+ return false;
+
// Give each item a chance to handle the key
foreach (ToolStripItem tsi in this.Items)
if (tsi.ProcessDialogKey (keyData))
@@ -993,10 +996,44 @@
if (this.ProcessArrowKey (keyData))
return true;
+ ToolStrip ts = null;
+
switch (keyData) {
case Keys.Escape:
this.Dismiss
(ToolStripDropDownCloseReason.Keyboard);
return true;
+
+ case Keys.Control | Keys.Tab:
+ ts = ToolStripManager.GetNextToolStrip
(this, true);
+
+ if (ts != null) {
+ foreach (ToolStripItem tsi in
this.Items)
+ tsi.Dismiss
(ToolStripDropDownCloseReason.Keyboard);
+
+
ToolStripManager.SetActiveToolStrip (ts);
+ ts.SelectNextToolStripItem
(null, true);
+ }
+
+ return true;
+ case Keys.Control | Keys.Shift | Keys.Tab:
+ ts = ToolStripManager.GetNextToolStrip
(this, false);
+
+ if (ts != null) {
+ foreach (ToolStripItem tsi in
this.Items)
+ tsi.Dismiss
(ToolStripDropDownCloseReason.Keyboard);
+
+
ToolStripManager.SetActiveToolStrip (ts);
+ ts.SelectNextToolStripItem
(null, true);
+ }
+
+ return true;
+ case Keys.Down:
+ case Keys.Up:
+ case Keys.Left:
+ case Keys.Right:
+ if (GetCurrentlySelectedItem () is
ToolStripControlHost)
+ return false;
+ break;
}
return base.ProcessDialogKey (keyData);
@@ -1292,25 +1329,63 @@
internal virtual bool ProcessArrowKey (Keys keyData)
{
+ ToolStripItem tsi;
+
switch (keyData) {
case Keys.Right:
+ tsi = this.GetCurrentlySelectedItem ();
+
+ if (tsi is ToolStripControlHost)
+ return false;
+
+ tsi = this.SelectNextToolStripItem
(tsi, true);
+
+ if (tsi is ToolStripControlHost)
+ (tsi as
ToolStripControlHost).Focus ();
+
+ return true;
case Keys.Tab:
- this.SelectNextToolStripItem
(this.GetCurrentlySelectedItem (), true);
+ tsi = this.GetCurrentlySelectedItem ();
+
+ tsi = this.SelectNextToolStripItem
(tsi, true);
+
+ if (tsi is ToolStripControlHost)
+ (tsi as
ToolStripControlHost).Focus ();
+
return true;
case Keys.Left:
+ tsi = this.GetCurrentlySelectedItem ();
+
+ if (tsi is ToolStripControlHost)
+ return false;
+
+ tsi = this.SelectNextToolStripItem
(tsi, false);
+
+ if (tsi is ToolStripControlHost)
+ (tsi as
ToolStripControlHost).Focus ();
+
+ return true;
case Keys.Shift | Keys.Tab:
- this.SelectNextToolStripItem
(this.GetCurrentlySelectedItem (), false);
+ tsi = this.GetCurrentlySelectedItem ();
+
+ tsi = this.SelectNextToolStripItem
(tsi, false);
+
+ if (tsi is ToolStripControlHost)
+ (tsi as
ToolStripControlHost).Focus ();
+
return true;
}
return false;
}
- internal virtual void SelectNextToolStripItem (ToolStripItem
start, bool forward)
+ internal virtual ToolStripItem SelectNextToolStripItem
(ToolStripItem start, bool forward)
{
ToolStripItem next_item = this.GetNextItem (start,
forward ? ArrowDirection.Right : ArrowDirection.Left);
this.ChangeSelection (next_item);
+
+ return next_item;
}
#region Stuff for ToolTips
Modified:
trunk/mcs/class/Managed.Windows.Forms/System.Windows.Forms/ToolStripControlHost.cs
===================================================================
---
trunk/mcs/class/Managed.Windows.Forms/System.Windows.Forms/ToolStripControlHost.cs
2007-04-30 16:11:26 UTC (rev 76503)
+++
trunk/mcs/class/Managed.Windows.Forms/System.Windows.Forms/ToolStripControlHost.cs
2007-04-30 17:43:32 UTC (rev 76504)
@@ -45,6 +45,7 @@
this.control = c;
this.control_align = ContentAlignment.MiddleCenter;
+ this.control.TabStop = false;
this.OnSubscribeControlEvents (this.control);
}
@@ -380,6 +381,11 @@
eh (this, e);
}
+ protected internal override bool ProcessDialogKey (Keys keyData)
+ {
+ return base.ProcessDialogKey (keyData);
+ }
+
protected override void SetVisibleCore (bool visible)
{
base.SetVisibleCore (visible);
@@ -456,6 +462,14 @@
#endregion
#region Private Methods
+ internal override void Dismiss (ToolStripDropDownCloseReason
reason)
+ {
+ if (this.Selected)
+ this.Parent.Focus ();
+
+ base.Dismiss (reason);
+ }
+
private void HandleEnter (object sender, EventArgs e)
{
this.OnEnter (e);
Modified:
trunk/mcs/class/Managed.Windows.Forms/System.Windows.Forms/ToolStripDropDown.cs
===================================================================
---
trunk/mcs/class/Managed.Windows.Forms/System.Windows.Forms/ToolStripDropDown.cs
2007-04-30 16:11:26 UTC (rev 76503)
+++
trunk/mcs/class/Managed.Windows.Forms/System.Windows.Forms/ToolStripDropDown.cs
2007-04-30 17:43:32 UTC (rev 76504)
@@ -562,6 +562,13 @@
protected override bool ProcessDialogKey (Keys keyData)
{
+ // We don't want to let our base change the active
ToolStrip
+ switch (keyData) {
+ case Keys.Control | Keys.Tab:
+ case Keys.Control | Keys.Shift | Keys.Tab:
+ return true;
+ }
+
return base.ProcessDialogKey (keyData);
}
@@ -849,12 +856,14 @@
return false;
}
- internal override void SelectNextToolStripItem (ToolStripItem
start, bool forward)
+ internal override ToolStripItem SelectNextToolStripItem
(ToolStripItem start, bool forward)
{
ToolStripItem next_item = this.GetNextItem (start,
forward ? ArrowDirection.Down : ArrowDirection.Up);
if (next_item != null)
this.ChangeSelection (next_item);
+
+ return (next_item);
}
private void ToolStripMenuTracker_AppFocusChange (object
sender, EventArgs e)
Modified:
trunk/mcs/class/Managed.Windows.Forms/System.Windows.Forms/ToolStripManager.cs
===================================================================
---
trunk/mcs/class/Managed.Windows.Forms/System.Windows.Forms/ToolStripManager.cs
2007-04-30 16:11:26 UTC (rev 76503)
+++
trunk/mcs/class/Managed.Windows.Forms/System.Windows.Forms/ToolStripManager.cs
2007-04-30 17:43:32 UTC (rev 76504)
@@ -499,7 +499,7 @@
if (AppClicked != null) AppClicked (null,
EventArgs.Empty);
if (Application.KeyboardCapture != null)
- Application.KeyboardCapture.KeyboardActive =
false;
+ Application.KeyboardCapture.Dismiss
(ToolStripDropDownCloseReason.AppClicked);
}
internal static void FireAppFocusChanged (Form form)
@@ -507,7 +507,7 @@
if (AppFocusChange != null) AppFocusChange (form,
EventArgs.Empty);
if (Application.KeyboardCapture != null)
- Application.KeyboardCapture.KeyboardActive =
false;
+ Application.KeyboardCapture.Dismiss
(ToolStripDropDownCloseReason.AppFocusChange);
}
internal static void FireAppFocusChanged (object sender)
@@ -515,7 +515,7 @@
if (AppFocusChange != null) AppFocusChange (sender,
EventArgs.Empty);
if (Application.KeyboardCapture != null)
- Application.KeyboardCapture.KeyboardActive =
false;
+ Application.KeyboardCapture.Dismiss
(ToolStripDropDownCloseReason.AppFocusChange);
}
private static void OnRendererChanged (EventArgs e)
_______________________________________________
Mono-patches maillist - [email protected]
http://lists.ximian.com/mailman/listinfo/mono-patches