* 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>
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
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 ();
click_mode = CaretSelection.Position;
}
+ click_point_x = e.X;
+ click_point_y = e.Y;
click_last = DateTime.Now;
}