PreferencesPanel and DrawableButton


#1

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();
        }

#2

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


#3

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; }

#4

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


#5

comes straight from the DrawableButton code.

comes straight from the DrawableButton code.


#6

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