WPF MouseEnter does not fire when MouseButton is Pressed - drag-and-drop

In short: If any mouse button is Pressed when the mouse enters a WPF window, all mouse events are ignored regardless of whether the mouse is captured by any process.
The Challenge
Create two WPF 4.5 projects. In the first one, add a Border with a MouseDown handler. Inside that handler, do everything you can think of to release mouse capture:
this.ReleaseMouseCapture();
element.ReleaseMouseCapture(); // "sender"
Mouse.Capture(null);
while (Mouse.Captured != null)
Mouse.Captured.ReleaseMouseCapture();
ReleaseCapture(); //Win32.ReleaseCapture()
In the other project, add a MouseEnter handler to the default grid that will change its Background.
Start them both up, MouseDown on the border and "drag" to the other window. Until you release the mouse button, the second Window's background will not change.
What's really annoying is that if you stay within the first window, the attempts to "uncapture" the mouse appear to work. Add another element in the first window with a MouseEnter handler, and it will fire just fine. This implies that WPF doesn't know or care about cross-process capture. It just ignores events if any mouse button is in the Pressed state when the mouse first enters an application.
Anyone know if it's possible to have WPF elements respond to mouse events when the mouse was pressed before entering them?

Related

GTK: How to determine ctl/alt key state when the mouse is clicked?

I know that I can get the ctl/alt key states from the keypress event when another key is pressed. But I can't find any way to detect the key state when, say, a mouse button is clicked. Yes, I get events when the ctl/alt keys are pressed and released, and I could keep track of whether they are up or down AS LONG AS the window stays in focus. But if the user, say, clicks on the desktop to take my window out of focus, then presses and holds the ctl or alt key down, and then clicks on my window, my code won't have seen the ctl key down event, and won't know it's down.
Is there a way to check the state of such modifier keys when a mouse click, or some other non-keyboard event, occurs?
Instead of trying to keep a state around permanently, check for modifiers every time you handle an event.
Examples:
https://developer.gnome.org/gtk3/stable/checklist-modifiers.html
Detect ctrl+click on button in pygtk

Mouse move message for child window are intercepted by parent, how to get them in child window's callback

I was writing an plugin of Adobe Illustrator. The Illustator UI has many non-modal dialogs (floating panels) in main window. I want to deal with the WM_MOUSEMOVE message of one panel. So I find the handle of the panel and use SetWindowLongPtr() to set a CALLBACK function of that panel, and use SetCapture() function to let it capture the mouse. But in the callback WM_MOUSEMOVE messages didn't come, however I use SPY++ to watch the panel and all WM_MOUSEMOVE messages were there. So I guess that the host application does something (maybe mouse hook?) to get the mouse messages and doesn't hand them to the panel's callback function.
What can I do to know where the host application intercepts the messages? It seems host will change the cursor when mouse moves to somewhere, how can I prevent it from setting the cursor?

hide cursor in mouse move handler and show it on mouse up

I'm developing a schematic editor, i need to hide the cursor when the middle key is down and moving, and show it again when the mouse up event occurs to implement an user friendly zooming system. The hide and show methods works fine when they are called from outside these event handlers, bud does not work when then called within the event handler!

GWT MouseClickEvent vs MouseDownEvent

Is there a standard way to separate MouseClick and MouseDown events in GWT?
If I click and hold button I still get MouseClick event together with MouseUp.
if I just click I still get MouseDown event together with MouseClick.
These events have some differences. Handle events which you need in a particular situation.
The thing is that in a general case ClickEvent includes MouseDownEvent and MouseUpEvent and cannot take place without of them. MouseDownEvent and MouseUpEvent precede ClickEvent. The same way as ClickEvent precedes DoubleClickEvent. But MouseDownEvent doesn't garantee that an ClickEvent will occur.
MouseDownEvent occurs every time when a user presses on one of the mouse buttons inside any element.
MouseUpEvent occurs when a user releases one of any mouse buttons.
and ClickEvent consists of both of these events. ClickEvent occurs when there're both these events on the same element. It's something like a combination of the mouse down and mouse up events. ClickEvent is generated only for the left mouse button unlike MouseDownEvent and MouseUpEvent.
That's ClickEvent is generated when a mouse is down then up while over an elem.
However, the mouse must stay within the same element, otherwise it won't occur.
For example, you pressed mouse down and moved outside of the element and release it. ClickEvent will not generated but MouseDownEvent will in this case.
And if you press mouse down and move outside the element, and move back in, then release it. ClickEvent will occur. And MouseDownEvent with MouseUpEvent will too.
If a user did click then this is the sequence of events:
MouseDownEvent
MouseUpEvent
ClickEvent
ClickEvent fires only after a user has released his mouse button.
Butt there's a way to create ClickEvent without generating of MouseDownEvent and MouseUpEvent:
click event will fire if a user used tab key to move the focus to a link and press Enter, but the MouseDown and MouseUp events will not.
Alternatively, you can open a link without generating ClickEvent:
click right button on a link and select on a item of dropdown list (in this case only MouseDownEvent and MouseUpEvent will fire)
also you can just pick up and drag a link to a new tab

Get click position on a canvas in a handler of a context-menu

I have an Eclipse RCP-Application, where a menu-contribution is registered, so that a context-menu will automatically be shown, when the user right-clicks on a special canvas in a defined view.
Now in some handlers I want to be able, to get the mouse coordinates, where the user clicked on the canvas, when the context-menu was shown. These handlers will be executed by commands, defined in this context-menu.
The ExecutionEvent in the execute-method of the handler doesn't provide this information.
How do I get the cursor position, the user clicked, to open the context-menu?
If the context menu is opened via a mouse event, then ExecutionEvent.getTrigger() will be the SWT MouseDown event, which includes the correct coordinates.