ImageButton not responding correctly to setInterceptsMouseClicks()

spotted a minor bug in ImageButton I think:  it does not respond correctly to setInterceptsMouseClicks(false, false), so will intercept mouse clicks anyway

The following modified hitTest() override fixes it for me (but perhaps there is a better way?)

bool hitTest(int x, int y) override 
                bool allowsClicksOnThisComponent = false;
                bool allowsClicksOnChildComponents = false;
                getInterceptsMouseClicks(allowsClicksOnThisComponent, allowsClicksOnChildComponents);
                if (!allowsClicksOnThisComponent)
                    return false;
                return ImageButton::hitTest(x, y);

btw tested this on Juce 3.3, but the v4 hitTest implementation looks identical


Well yes, button classes don't really expect you to suddenly make them transparent to mouse-clicks, as that kind of defeats the purpose of a button!

A cleaner way to write the test in your override would probably be to just do

return Component::hitTest (x, y) && ImageButton::hitTest (x, y);

that's more elegant indeed!   btw need it for a little layout editor I'm writing: buttons just need to render in the editor, but should refrain from handling mouse events. Instead, their parent wrapper component handles click&drag for moving the button around within the layout

It's actually a valid feature request, I should probably just add this to the ImageButton class, as it's only a tiny change and won't break anything else..