MouseClick Event not raised for AppHooks


I was poking around with the Hook Listener demo and noticed it wasn't raising MouseClick events unless the hook was a global. As currently I only want to capture mouse events on a single window, I don't want to enable a global handler.
I had a quick look at ProcessMouseClick in MouseHookListener.cs and found it would only raise the event if m_DownButtonsWaitingForMouseUp was set. This variable is only set for global hooks according to a comment in the same file.
I changed the if statement in the ProcessMouseClick function to
if ((!IsGlobal && e.Button != MouseButtons.None) || (IsGlobal && (m_DownButtonsWaitingForMouseUp & e.Button) != MouseButtons.None))
This then allowed me to correctly catch click events on the app hooks.
I considered creating a patch, but as it's only one line of code and not knowing how the rest of the system works it's possible that my fix isn't the best way of doing it, therefore I've just logged this issue so you're aware of the bug and can fix it however you see fit.
Richard Moss


gmamaladze wrote Feb 3, 2012 at 6:54 PM

Need to be reproduced, fixed and tested.

wrote Feb 3, 2012 at 6:55 PM

wrote Feb 21, 2013 at 11:19 PM

wrote Jan 13, 2015 at 12:35 PM

jmwhitmire wrote Jan 13, 2015 at 12:38 PM

I saw the same thing and came to the same conclusion... and then I found this discussion. (I should have searched first!)