- Constrain the double click handler to the double click size.
authorJackson Harper <jackson@novell.com>
Fri, 8 Dec 2006 19:02:41 +0000 (19:02 -0000)
committerJackson Harper <jackson@novell.com>
Fri, 8 Dec 2006 19:02:41 +0000 (19:02 -0000)
svn path=/trunk/mcs/; revision=69235

mcs/class/Managed.Windows.Forms/System.Windows.Forms/ChangeLog
mcs/class/Managed.Windows.Forms/System.Windows.Forms/TextBoxBase.cs

index fd6a63532dd9746584a77da3471d1a311712b0af..1f13a20992a1e6b48046b5ffc91e46ecdd2e0137 100644 (file)
@@ -3,6 +3,7 @@
        * TextBoxBase.cs: Reworked the mouse down code so I could get it
        to behave like MS, we now ignore the eventargs.Click and just
        track state ourself, which we were already doing anyways.
+       - Constrain the double click handler to the double click size.
        
 2006-12-08  Chris Toshok  <toshok@ximian.com>
 
index bce6ea190468e0ceb6cf00f3a17a3e840400029b..6e35a6bf4098c309cf7e8866c938915b4d694dbc 100644 (file)
@@ -70,6 +70,8 @@ namespace System.Windows.Forms {
                static internal int             track_width = 2;        //
                static internal int             track_border = 5;       //
                internal DateTime               click_last;
+               internal int                    click_point_x;
+               internal int                    click_point_y;
                internal CaretSelection         click_mode;
                internal Bitmap                 bmp;
                #if Debug
@@ -1463,15 +1465,26 @@ namespace System.Windows.Forms {
                        base.OnLostFocusInternal (e);
                }
 
+               private bool IsDoubleClick (MouseEventArgs e)
+               {
+                       TimeSpan interval = DateTime.Now - click_last;
+                       if (interval.TotalMilliseconds > SystemInformation.DoubleClickTime)
+                               return false;
+                       Size dcs = SystemInformation.DoubleClickSize;
+                       if (e.X < click_point_x - dcs.Width / 2 || e.X > click_point_x + dcs.Width / 2)
+                               return false;
+                       if (e.Y < click_point_y - dcs.Height / 2 || e.Y > click_point_y + dcs.Height / 2)
+                               return false;
+                       return true;
+               }
+
                private void TextBoxBase_MouseDown (object sender, MouseEventArgs e)
                {
                        if (e.Button == MouseButtons.Left) {
-                               TimeSpan interval;
-
-                               interval = DateTime.Now - click_last;
+                               
                                document.PositionCaret(e.X + document.ViewPortX, e.Y + document.ViewPortY);
 
-                               if (interval.TotalMilliseconds < SystemInformation.DoubleClickTime) {
+                               if (IsDoubleClick (e)) {
                                        switch (click_mode) {
                                        case CaretSelection.Position:
                                                SelectWord ();
@@ -1503,6 +1516,8 @@ namespace System.Windows.Forms {
                                        click_mode = CaretSelection.Position;
                                }
 
+                               click_point_x = e.X;
+                               click_point_y = e.Y;
                                click_last = DateTime.Now;
                        }