Mouse Callbacks trouble


I’m have some troubles with the mouseDown, mouseDrag, etc… callbacks on a component.

The component Bounds are defines in the MainComponent.

The component is a rectangle and have a children.
I want to move the children in this component with the mouseDrag callback, and updating the coordinates of the children to use them after.

So the mouse callbacks works but only along the top line of the rectangle (along the x axis at y=0 of the rectangle) and I don’t understand why…

Thanks !

GUI.h (2.4 KB)

There’s some things not quite right in your code. You don’t need to use a timer for this.

I created a small example for you. It uses a ComponentDragger and a ComponentBoundsConstrainer. It constrains the movement to the actual bounds of the parent component. Take a look at the documentation of those two classes.

This is a PIP, you can open it in Projucer and save it as a regular project.
Drag.h (2.3 KB)

1 Like

Thank you !
It’s exactly what I need !

I have another trouble : I use a multidocumentpanel in the component that contain the “Drag” in your code and it seems that the multidocumentpanel stop the mouse callbacks…
Do you know how to fix it ?

Thanks !
GUI.h (4.2 KB)