ShapeButton HitTest


#1

Hey,

Currently the shapeButton does not actually check if a mouse event is inside the path that was set for the button.
Say if the button is showing as a circle, clicks or mouse downs that occur in the shape's rectangular bounding box are also registered (which is very un-intuitive, especially for an amateur JUCE user like me).

Do you think you could just add a hitTest() to the ShapeButton class, like so:

 

bool ShapeButton::hitTest(int x, int y)
{
    return shape.contains(x, y);
}

 

This would make the ShapeButton actually behave like a "Shape Button".

 

Thanks

 


#2

Mostly people will use ShapeButton for icons. Icons tend to have holes in the path. Can you imagine how irritating it'd be to have an icon where you can only click on the solid parts of the shape, and not inside any holes in the image!

I certainly can't think of any places where I've ever used a shape button where I'd want it to behave like that, and if you did want to do so, it's simple for someone to write their own derived class, override hitTest, and use either the path or some other path to do whatever custom testing they need.


#3

I see. I didn't realize the icons part.
My application required to create pie-chart segments where each segment was to be a button. So I just extended the shapeButton by adding a hitTest.