Author: ivanz
Date: 2008-02-16 12:59:53 -0500 (Sat, 16 Feb 2008)
New Revision: 95908

Modified:
   
branches/mono-1-9/mcs/class/Managed.Windows.Forms/System.Windows.Forms/ChangeLog
   
branches/mono-1-9/mcs/class/Managed.Windows.Forms/System.Windows.Forms/PropertyGridTextBox.cs
   
branches/mono-1-9/mcs/class/Managed.Windows.Forms/System.Windows.Forms/PropertyGridView.cs
Log:
2008-02-16  Ivan N. Zlatev  <[EMAIL PROTECTED]>

        [Backport to 1.9]
        * 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: 
branches/mono-1-9/mcs/class/Managed.Windows.Forms/System.Windows.Forms/ChangeLog
===================================================================
--- 
branches/mono-1-9/mcs/class/Managed.Windows.Forms/System.Windows.Forms/ChangeLog
    2008-02-16 17:57:46 UTC (rev 95907)
+++ 
branches/mono-1-9/mcs/class/Managed.Windows.Forms/System.Windows.Forms/ChangeLog
    2008-02-16 17:59:53 UTC (rev 95908)
@@ -1,6 +1,14 @@
 2008-02-16  Ivan N. Zlatev  <[EMAIL PROTECTED]>
 
        [Backport to 1.9]
+       * 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]
+
+2008-02-16  Ivan N. Zlatev  <[EMAIL PROTECTED]>
+
+       [Backport to 1.9]
        * PropertyGrid.cs: Clear current items first thing before 
        repopulating subitems.
        * GridEntry.cs: 

Modified: 
branches/mono-1-9/mcs/class/Managed.Windows.Forms/System.Windows.Forms/PropertyGridTextBox.cs
===================================================================
--- 
branches/mono-1-9/mcs/class/Managed.Windows.Forms/System.Windows.Forms/PropertyGridTextBox.cs
       2008-02-16 17:57:46 UTC (rev 95907)
+++ 
branches/mono-1-9/mcs/class/Managed.Windows.Forms/System.Windows.Forms/PropertyGridTextBox.cs
       2008-02-16 17:59:53 UTC (rev 95908)
@@ -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: 
branches/mono-1-9/mcs/class/Managed.Windows.Forms/System.Windows.Forms/PropertyGridView.cs
===================================================================
--- 
branches/mono-1-9/mcs/class/Managed.Windows.Forms/System.Windows.Forms/PropertyGridView.cs
  2008-02-16 17:57:46 UTC (rev 95907)
+++ 
branches/mono-1-9/mcs/class/Managed.Windows.Forms/System.Windows.Forms/PropertyGridView.cs
  2008-02-16 17:59:53 UTC (rev 95908)
@@ -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));
+                                       }
                                }
                        }
                }

_______________________________________________
Mono-patches maillist  -  [email protected]
http://lists.ximian.com/mailman/listinfo/mono-patches

Reply via email to