FR: Components can receive mouseEnter with pressed button

button
mouseenter

#1

In some occasions it is necessary to receive mouseEnter and mouseExit events regardless if the button is pressed or not. So please add the following feature:

Add a flag to Component named similar: receivesMouseEnterExitWhileButtonPressed (bool enter, bool exit). Default should be false to keep current behaviour.

A usecase is given in this thread: Toggle buttons when swiping over a row


#2

I actually think the best way to implement this would be with the same trick that I’ve been meaning to add for a while, i.e. a new mouse method called mouseCancel(), and a mechanism by which you can steal the mouse from the currently-dragged component. The main motivator for adding this would be for gesture detection to be able to handle things like someone pressing a button, but then spotting that the movement is actually a swipe, and stealing the input from that button without it triggering a mouseUp. In your case, a group of buttons could watch for when the mouse is dragged outside themselves onto another button, and then relinquish the event, allowing the other one to take over.


#3

Thanks @jules, that sounds like a sensible workflow.
But do I get that right, that it is not possible currently?

If I would do this:

void mouseMoved (const MouseEvent& e)
{
    if (!getLocalBounds().contains (e.getPosition())
        e.cancelDrag();
}

Would that automatically create a mouseExit event? And a mouseEnter to the new component?

What about the mouseUp and mouseDown? They would probably not occur then, but maybe that is a good thing?


#4

Yeah, it’s not possible at the moment, it’s something that would need to be added to the MouseInputSource.