[Mono-patches] r95907 - trunk/mcs/class/Managed.Windows.Forms/System.Windows.Forms
Ivan N. Zlatev (contact@i-nz.net)
mono-patches-list at lists.ximian.com
Sat Feb 16 12:57:46 EST 2008
Author: ivanz
Date: 2008-02-16 12:57:46 -0500 (Sat, 16 Feb 2008)
New Revision: 95907
Modified:
trunk/mcs/class/Managed.Windows.Forms/System.Windows.Forms/PropertyGridTextBox.cs
trunk/mcs/class/Managed.Windows.Forms/System.Windows.Forms/PropertyGridView.cs
Log:
2008-02-16 Ivan N. Zlatev <contact at i-nz.net>
* PropertyGridTextBox.cs, PropertyGridView.cs: Explicitly send
a mouse down event to the textbox so that we get the caret
positioned under cursor.
[Fixes bug #362119]
Modified: trunk/mcs/class/Managed.Windows.Forms/System.Windows.Forms/PropertyGridTextBox.cs
===================================================================
--- trunk/mcs/class/Managed.Windows.Forms/System.Windows.Forms/PropertyGridTextBox.cs 2008-02-16 17:21:27 UTC (rev 95906)
+++ trunk/mcs/class/Managed.Windows.Forms/System.Windows.Forms/PropertyGridTextBox.cs 2008-02-16 17:57:46 UTC (rev 95907)
@@ -28,18 +28,27 @@
using System;
using System.Drawing;
-namespace System.Windows.Forms.PropertyGridInternal {
- internal class PGTextBox : TextBox {
- internal bool SwallowCapture = false;
-
- internal override bool InternalCapture {
- get {
- return base.InternalCapture;
+namespace System.Windows.Forms.PropertyGridInternal
+{
+ internal class PGTextBox : TextBox
+ {
+ private bool _focusing = false;
+
+ public void FocusAt (Point location)
+ {
+ _focusing = true;
+ Point pnt = PointToClient (location);
+ XplatUI.SendMessage (Handle, Msg.WM_LBUTTONDOWN, new IntPtr ((int)MsgButtons.MK_LBUTTON), Control.MakeParam (pnt.X, pnt.Y));
+ }
+
+ protected override void WndProc (ref Message m)
+ {
+ // Swallow the first MOUSEMOVE after the focusing WM_LBUTTONDOWN
+ if (_focusing && m.Msg == (int)Msg.WM_MOUSEMOVE) {
+ _focusing = false;
+ return;
}
- set {
- if (!SwallowCapture)
- base.InternalCapture = value;
- }
+ base.WndProc (ref m);
}
}
@@ -102,6 +111,8 @@
protected override void OnGotFocus (EventArgs args)
{
base.OnGotFocus (args);
+ // force-disable selection
+ textbox.has_been_focused = true;
textbox.Focus ();
textbox.SelectionLength = 0;
}
@@ -218,6 +229,13 @@
#endregion Private Helper Methods
+ internal void SendMouseDown (Point screenLocation)
+ {
+ Point clientLocation = PointToClient (screenLocation);
+ XplatUI.SendMessage (Handle, Msg.WM_LBUTTONDOWN, new IntPtr ((int) MsgButtons.MK_LBUTTON), Control.MakeParam (clientLocation.X, clientLocation.Y));
+ textbox.FocusAt (screenLocation);
+ }
+
private void textbox_DoubleClick(object sender, EventArgs e) {
EventHandler eh = (EventHandler)(Events [ToggleValueEvent]);
if (eh != null)
Modified: trunk/mcs/class/Managed.Windows.Forms/System.Windows.Forms/PropertyGridView.cs
===================================================================
--- trunk/mcs/class/Managed.Windows.Forms/System.Windows.Forms/PropertyGridView.cs 2008-02-16 17:21:27 UTC (rev 95906)
+++ trunk/mcs/class/Managed.Windows.Forms/System.Windows.Forms/PropertyGridView.cs 2008-02-16 17:57:46 UTC (rev 95907)
@@ -218,8 +218,10 @@
foundItem.Expanded = !foundItem.Expanded;
this.property_grid.SelectedGridItem = foundItem;
- if (!GridLabelHitTest (e.X))
- FocusSelection ();
+ if (!GridLabelHitTest (e.X)) {
+ // send mouse down so we get the carret under cursor
+ grid_textbox.SendMouseDown (PointToScreen (e.Location));
+ }
}
}
}
More information about the Mono-patches
mailing list