You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Hello,
I needed a fast way to detect a mouse double-click, I used the DoubleClick event but I found it slow for some reason,
After a quick look, I figured out why, it never catches the WM_LBUTTONDBLCLK message (I've implemented my mouse low-level hook and the WM_LBUTTONDBLCLK message isn't fired at all).
So in the LowLevelMouseHook class the isDoubleClick never true,
and the DoubleClick event is fired on the mouseUp portion:
if (mouseUp)
{
OnUp(args);
PreviousDownTimeDictionary.TryGetValue(key, out var previousDateTime);
if (DateTime.Now.Subtract(previousDateTime) < DoubleClickSpeed)
{
OnDoubleClick(args);
}
}
Which is not that fast because at the second click the user might be slow to release it.
So I think it would be better to check for double-click on the mouseDown portion (Which isn't always what everyone needs)
So an option to choose would be much better.
The other thing that I noticed is the current implementation checks for timing using DateTime.Now, I think it would be better to use Environment.TickCount
Here is how I solved the issue:
private static void MouseHookOnDown(object? _, MouseEventArgs e)
{
if (e.CurrentKey != Key.MouseLeft) return;
var now = Environment.TickCount;
if (now - _lastClickTime < 400)
{
// Double-click detected
}
_lastClickTime = now;
}
Thank you for your awesome work <3
The text was updated successfully, but these errors were encountered:
Hello,
I needed a fast way to detect a mouse double-click, I used the
DoubleClick
event but I found it slow for some reason,After a quick look, I figured out why, it never catches the
WM_LBUTTONDBLCLK
message (I've implemented my mouse low-level hook and theWM_LBUTTONDBLCLK
message isn't fired at all).So in the
LowLevelMouseHook
class theisDoubleClick
never true,and the
DoubleClick
event is fired on themouseUp
portion:Which is not that fast because at the second click the user might be slow to release it.
So I think it would be better to check for double-click on the
mouseDown
portion (Which isn't always what everyone needs)So an option to choose would be much better.
The other thing that I noticed is the current implementation checks for timing using
DateTime.Now
, I think it would be better to useEnvironment.TickCount
Here is how I solved the issue:
Thank you for your awesome work <3
The text was updated successfully, but these errors were encountered: