mouseInputSource::getComponentUnderMouse() nullptr after an unbounded movement

gui
#1

Hey,

I want to zoom into a timeline, using an unbounded mouse drag.
At the end of the mouse drag, if I am careful not to move the mouse at all when I release the mouse click (mouseUp without further mouseMove), the mouse is “out” of the window :
every call to mouseInputSource::getComponentUnderMouse() returns nullptr, as if the window had lost it’s focus.

After a 1pixel mouseMove, everything returns to normal.

Do you know how to force the mouse to re-enter into the window ? I have tried mouseInputSource.setScreenPosition() but this does not trigger any mouse event.

Best,

PS: at the mouseUp end of the unbounded movement, I call mouseInputSource::enableUnboundedMouseMovement(false) to trigger the unavoidable setPosition caused by the unbounded movement, and then I call mouseInputSource.setScreenPosition() to replace the mouse where I want (at the new position in the timeline). My theory is that the last known position of the mouseInputSource is still “outside” of the window since it was there at the end of the unbounded movement.

0 Likes

#2

Followup: with some help, the solution that seeems to work is “avoid being outside of the component at all”.

What I ended up doing is : inside the mouseDrag callback, I continuously adjust the mouse position back inside the component.

Then the mouseUp end of the unbounded movement, I call mouseInputSource::enableUnboundedMouseMovement(false) and nothing happens because the mouse is inbounds. Then I don’t have to call mouseInputSource.setScreenPosition() to replace the mouse where I want (at the new position in the timeline) because it has been continuously replaced at this position already.

0 Likes