DragableCircle comoponent does not respond to mouse click


#1

Hi,
My program has a component which owns an array of 2 DragableCircle Components.
the problem is that when I initialize this array the first component that being added to the parent is always disabled (does not respond to mouse click).
They are both initialize in a loop, so it is exactly the same code for these two items.

Do you have any idea what might be the reason?

thanks


#2

The reason is probably the Z-order. The mouse events are passed to the components from front to back. If your DragableCircle Components are siblings to the component that owns them, it is possible, that they are obstructed.
It all depends on how you call addAndMakeVisible (which makes them effectively parent and child components), and not which components own them.
You can change the Z-order of siblings by calling Component::toFront().
If you want a Component to ignore mouse clicks, override Component::hitTest() to return false.

Hope that helps