My app looks like this:
I refactored my UI code and am bumping into some hitTest troubles.
Wheel has 12 spokes.
Each spoke has a Path “clickable” and a slider (rotated using AffineTransform).
Here’s the wheel:
struct PaneWheel : public Component {
juce::OwnedArray<Slice> slices;
bool hitTest(int x, int y) final {
for(auto slice : slices)
if(slice->hitTest(x, y))
return true;
return false;
}
Given I’m manually overriding hitTest IIUC setInterceptsMouseClicks would be redundant.
Here’s a spoke:
struct Slice : Component
Slider slider;
Path buttonOutline;
bool hitTest(int x, int y) final {
return buttonOutline.contains(x, y) || slider.hitTest(x, y);
Running the new code, I’m no longer able to click the Path objects, and only slider #11 can be changed by L-mouse-down+drag.
I suppose slider #11 is rendered last, so is on top. And it’s eating all mouse events by the looks of it.
It appears that slider.hitTest(x, y) is always returning true, for ALL x,y and for ALL 12 sliders.
Changing this line:
bool hitTest(int x, int y) final {
return buttonOutline.contains(x, y); // || slider.hitTest(x, y);
… now the Path shapes work, but of course none of the sliders respond.
I can’t figure out why this is failing, yet the pre-refactored code worked.
In that code (in the wheel) I had:
struct Slice : Component {
Slice(int i) {
setInterceptsMouseClicks(false, true); // allowClicks allowClicksOnChildComponents
}
}
struct PaneWheel : public Component {
juce::OwnedArray<Slice> slices;
OwnedArray<Path> paths;
bool hitTest(int x, int y) final {
for(auto p : paths)
if(p->contains(x, y))
return true;
// https://forum.juce.com/t/hittest-ignore-setinterceptsmouseclicks/48006/11
// > If hitTest of the parent returns false, it will not try the children
for (auto* child : getChildren())
if (child->hitTest (x, y))
return true;
return false;
}
void mouseUp(const MouseEvent& event) final
{
auto xy = event.getPosition().toFloat();
for(int i=0; i<12; ++i)
if(paths[i]->contains(xy))
DBG("MouseUp:" + String(i));
}
My refactor was to move the Path for each of the 12 buttons from the PaneWheel component into the Slice.
Can anyone see what I’m doing wrong?
Could there be some problem passing x, y to hitTest on an affineTransformed slider? e.g. might I need to manually transform x and y into the slider’s coord-system?
EDIT: I tried:
float _x = x, _y = y;
slider.getTransform().transformPoint(_x, _y);
if(slider.hitTest(_x, _y))
return true;
… in my hitTest but still it is always returning true.

