PreferencesPanel and DrawableButton

hi,

I wanted more control over the DrawableButtons than what’s available by default with PreferencesPanel (different images when toggle state is true).
So after adding the pages with addSettingsPage(“page name”, NULL, NULL);

I then scan the child components and explicitly call setImages(). the problem is that afterward the button is clickable everywhere but not on the icon image anymore.
I had to use a custom Drawable image with a custom hitTest and createCopy to avoid that.

looking briefly at the Drawable button code my patch shouldn’t be necessary, the following code is already enough to avoid the custom hitTest but it doesn’t work in my case:

        if (currentImage != 0)
        {
            currentImage->setInterceptsMouseClicks (false, false);
            addAndMakeVisible (currentImage);
            DrawableButton::resized();
        }

I fixed a bug last week in DrawableImage::hitTest() - have you grabbed that latest version?

here is mine:

bool DrawableImage::hitTest (int x, int y)
{
    return image.isValid() && image.getPixelAt (x, y).getAlpha() >= 127;
}

but I had to disable it like that with a CustomDrawableImage as a workaround:

virtual bool hitTest(int,int) { return false; }

Yes, it’s ignoring your setInterceptsMouseClicks() setting, I guess I should make it check that too.


comes straight from the DrawableButton code.

comes straight from the DrawableButton code.

I updated the class now, so that you should be able to use setInterceptsMouseClicks