From 7843c9ad2d46e55178d14d0f02b5185ab36e7181 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Jean-Philippe=20Bruy=C3=A8re?= Date: Tue, 2 Jun 2020 02:26:49 +0200 Subject: [PATCH] mouse repeat --- Crow/src/IML/Instantiator.cs | 2 +- Crow/src/Interface.cs | 25 ++++++++++++------------- 2 files changed, 13 insertions(+), 14 deletions(-) diff --git a/Crow/src/IML/Instantiator.cs b/Crow/src/IML/Instantiator.cs index 4254933b..9451f6ed 100644 --- a/Crow/src/IML/Instantiator.cs +++ b/Crow/src/IML/Instantiator.cs @@ -526,7 +526,7 @@ namespace Crow.IML { if (imlValue.StartsWith ("{", StringComparison.Ordinal)) readPropertyBinding (ctx, reader.Name, imlValue.Substring (1, reader.Value.Length - 2)); else - CompilerServices.EmitSetValue (ctx.il, pi, styledValue); + CompilerServices.EmitSetValue (ctx.il, pi, imlValue); } reader.MoveToElement (); diff --git a/Crow/src/Interface.cs b/Crow/src/Interface.cs index 721404d2..adae26bc 100644 --- a/Crow/src/Interface.cs +++ b/Crow/src/Interface.cs @@ -309,9 +309,9 @@ namespace Crow /// Double click threshold in milisecond public static int DOUBLECLICK_TRESHOLD = 320;//max duration between two mouse_down evt for a dbl clk in milisec. /// Time to wait in millisecond before starting repeat loop - public static int DEVICE_REPEAT_DELAY = 700; + public static int DEVICE_REPEAT_DELAY = 600; /// Time interval in millisecond between device event repeat - public static int DEVICE_REPEAT_INTERVAL = 40; + public static int DEVICE_REPEAT_INTERVAL = 100; public static float WheelIncrement = 1; /// Tabulation size in Text controls public static int TAB_SIZE = 4; @@ -769,15 +769,15 @@ namespace Crow for (int i = 0; i < tmpThreads.Length; i++) tmpThreads [i].CheckState (); - //if (mouseRepeatTimer.ElapsedMilliseconds > 0) { - // if ((bool)_hoverWidget?.MouseRepeat) { - // int repeatCount = (int)mouseRepeatTimer.ElapsedMilliseconds / DEVICE_REPEAT_INTERVAL - mouseRepeatCount; - // for (int i = 0; i < repeatCount; i++) - // _hoverWidget.onMouseDown (_hoverWidget, lastMouseDownEvent); - // mouseRepeatCount += repeatCount; - // } - //} else if (lastMouseDown.ElapsedMilliseconds > DEVICE_REPEAT_DELAY) - //mouseRepeatTimer.Start (); + if (lastMouseDownEvent != null) { + if (mouseRepeatTimer.ElapsedMilliseconds > DEVICE_REPEAT_INTERVAL) { + if (_hoverWidget != null && _hoverWidget.MouseRepeat) { + _hoverWidget.onMouseDown (_hoverWidget, lastMouseDownEvent); + mouseRepeatTimer.Restart (); + } + } else if (lastMouseDown.ElapsedMilliseconds > DEVICE_REPEAT_DELAY) + mouseRepeatTimer.Start (); + } if (!Monitor.TryEnter (UpdateMutex)) return; @@ -1143,7 +1143,6 @@ namespace Crow Stopwatch lastMouseDown = Stopwatch.StartNew (), mouseRepeatTimer = new Stopwatch (); bool doubleClickTriggered; //next mouse up will trigger a double click - //int mouseRepeatCount; MouseButtonEventArgs lastMouseDownEvent; public Point MousePosition { get; set; } = default; @@ -1265,7 +1264,6 @@ namespace Crow { doubleClickTriggered = (lastMouseDown.ElapsedMilliseconds < DOUBLECLICK_TRESHOLD); lastMouseDown.Restart (); - //mouseRepeatCount = -1;//stays negative until repeat delay is hit lastMouseDownEvent = new MouseButtonEventArgs (MousePosition.X, MousePosition.Y, button, InputAction.Press); @@ -1285,6 +1283,7 @@ namespace Crow public virtual bool OnMouseButtonUp (MouseButton button) { mouseRepeatTimer.Reset (); + lastMouseDownEvent = null; MouseButtonEventArgs e = new MouseButtonEventArgs (MousePosition.X, MousePosition.Y, button, InputAction.Repeat); if (_activeWidget == null) -- 2.47.3