Hello everyone! I’m quite new to C++ and Juce, but I have read the tutorial and made some progress. Until now. I was wondering if maybe someone could give me a little help…
What I want to do:
Draw several non-rectangular and possibly overlapping shapes in a component and be able to select one of them with a mouse click.
I can think of two ways to do it:
A) The shapes could all be drawn drawn in the paint method of the background class which also captures the mouse clicks. When mouse clicks are detected the coordinates could be compared with the position data of each shape to find out which one was clicked. Seems awkward.
B) The shapes could be created as objects from a class that inherit from Component and each would draw itself in its on paint() method. That would mean there would be many layers of rectangular components over the background/container class that holds all the objects. Those componsents would be of the same size size as the background to have the same coordinate system, and be mostly transparent apart from pixels occupied by the shape.
How can I detect which one was clicked in this case?
Is there a way of capturing mouse clicks only on the parts of a component that are visible?