How to get MouseEvents when dragging over multiple controls?


#1

article removed


#2

I wouldn’t recommend ever manually invoking a mouseDown callback… It seems like a straightforward thing to do, but I’ve been bitten many times by subtle problems caused by the myriad of things that might happen during a mouseDown call (usually involving deletion of the parent component that’s making the call).

A better design would be to make the child components process the mouse event themselves, but make them perform their function via a model class, rather than altering themselves or other components directly. Tell the model what the event means, let the model update itself accordingly, and then let all the UI components respond to changes in the model.


#3

[quote=“jules”]I
A better design would be to make the child components process the mouse event themselves, but make them perform their function via a model class, rather than altering themselves or other components directly. Tell the model what the event means, let the model update itself accordingly, and then let all the UI components respond to changes in the model.[/quote]

That’s true, :slight_smile:
Which translates to: dont call mouseDown directly, but perform what you have inside the method.
In my case its the translation of mouse information to a parameter value of the model.

void Control::mouseDown (const MouseEvent& e) { if( actuator ) { float input = actuator->down(e.x, e.y); setValue(input); } }

BTW, this was the original problem:
http://www.rawmaterialsoftware.com/viewtopic.php?f=2&t=3336

Are there other known solutions?
I wished mouseEnter and mouseExit or something similar would be called from the system, while I’m dragging.


#4

Personally, I’d probably make all the components ignore mouse clicks, let all the mouse clicks go straight to the parent, and deal with it there.