What is the low-level trigger for Windows Click events - windows

The standard sequence of events to trigger a mouse click in Windows is documented here:
MSDN
Essentially it is:
MouseDown event.
Click event.
MouseClick event.
MouseUp event.
However, I have a control which is altering the sequence of events by capturing events on its children (to implement dragging). That means that the full sequence might not execute, e.g. currently I have a button which sees a MouseDown event, but no MouseUp event when the mouse is clicked.
Therefore the question is, what actually triggers the click at a low-level? Does it need a MouseDown followed by a MouseUp. Will a MouseUp on its own be sufficient? Are there any other considerations?

Related

How to properly override mouse events in other apps (Windows)?

I'm trying to implement system-wide drag operation with middle mouse button. It should override middle mouse drag behavior in other programs. Currently, I am handling global mouse events with system-wide hooks.
Problem is - many programs still receive and handle same events like I did not intercept them.
Here's what I tried:
not call the next hook for mouse down event: I never receive mouse up, so I don't know where and when to stop dragging
not call the next hook for mouse move: cursor slows down tremendously
not call the next hook for mouse up: most windows in the system stop reacting to mouse events completely after my drag is finished
always call the next hook in the chain: if the control under mouse has scroll in it, most of the time it will be scrolling while my drag is in progress. Also UWP apps continue receiving mouse events during my drag, so if a link in MS Edge happens to be under cursor when it started, and mouse does not leave Edge boundary, Edge receives click event, and new tab is opened
What I need is: when user holds middle mouse and starts dragging, my drag handler should be called, and no other handlers, like file drag, scroll, etc should happen.
I ended up with somewhat hacky solution:
do not call the next hook for mouse down for middle button
record where it was pressed
when handling mouse up, if user did not drag - replay the whole mouse up + mouse down using SendInput from a separate thread (to avoid deadlock due to reentrancy)

FireMonkey - how to capture TScrollBar mouse events?

I'm trying to capture mouse events on a TScrollBar. In design time, I created a handler for each mouse event, on the Events tab of the Object Inspector. At runtime, the TScrollBar does not fire the mouse events, therefore the handlers are not executed. For instance, when the mouse pointer enters the TScrollBar, the OnMouseEvent never triggers the associated ScrollBarMouseEnter. I'm working with FireMonkey, Berlin 10.1 Update 2, Win32 platform. Any help would be appreciated.

When is a button "clicked"?

Most mouse-APIs allow one to check weather or not a mouse button was pressed or released. As an example: The Java-Swing-API also allows to check for a "click" event, that is just an additional event that get's triggered whenever a "release" event was triggered after a "press" event, though it is hard to imagine to a scenario where this does not happen.
When implementing my own UI with a common mouse API, I now wonder how to register a "click" upon a general button. I went ahead and checked various UIs used by various programs I use and I got the general feel that any button is considered "clicked" when the mouse button is released above it.
They do not require the mouse-button to be "pressed" above them before being "released". It seems the "pressed"-event only tries to catch an object to be "dragged", though most mouse-APIs have their own "dragged" event to be triggered, the "pressed" event seems to be used to select the item that should be dragged.
Then right as I write this, it seems that browsers do not allow button presses when the mouse was not "pressed" upon the button before being "released" above it.
Question 1: Do I miss something here or am I right in these observations?
As such, a "UI"-Class managing the components of any UI needs to consider:
It's components to be drawn
The components that are focused
The components that have been "pressed" and are as such "dragged"
A "click" is triggered simply when the mouse button is "released" upon all components that are "focused". Or a "click" is triggered upon all components that were "pressed" and are still "focused"?
Question 2/3: Will this implementation be a good start or do I miss something? Which one is better?
Question 1:
Pressed: event is generated when you push down the mouse button
Released: event is generated when you release the mouse button (which has been pressed down before)
Clicked: event is generated when a mouse button Pressed & Released.

Detect mouse right ckick on combobox

How to detect a mouse click (or mousedown) event on a simple dropdown combo (combobox with style=1)?
I am unable to see mouseclick or mousedown event handlers for combobox in my vb6 IDE.
My aim is to detect right click.
Thanks in advance.
If the events aren't exposed, you may need to subclass the control and handle the WM_RBUTTONDOWN message.

gwt mouse over events not fired when mouse button is down

When you push down the left mouse button mouse down event fires. If you then move the mouse over a label (while holding the mouse button down) mouse over event does not fire.
Is there any way to enable this events or fire them manualy or simulate them?
What you are actually doing is two separate events, one is a mouse down event as you have described and the other is a mouse drag.
If you want to simulate them, that you might have to consider using a mouse click to track the user's (x,y) location. Subsequently, if you want to "simulate" it you could do some computation and decide for yourself if it is indeed a mouse click or mouse drag event that has occurred.
Hope it helps :) Cheers!

Resources