Help with ShapeButton not drawing

So I’ll preface this by saying I’m pretty new to C++ and only a few days old using Juce, so it’s likely this is super obvious and a quick fix but it’s been stumping me.

I wasn’t sure how to override hitTest() without creating a new class, so I’ve created a new ShapeButton class in order to make sure that clicks only register on the circular shape I’ve created for the buttons. The problem I’m having is that it doesn’t seem to draw the shape. If I change the declaration to a ShapeButton instead of my new inheriting class, the code works just fine changing nothing else which seems to point to something in the new class but I can’t seem to figure it out.

Here’s my new class:

class GuessCircle : public juce::ShapeButton
{
public:
//==============================================================================
GuessCircle(juce::String name, juce::Colour color1, juce::Colour color2, juce::Colour color3):ShapeButton(name, color1, color2, color3)
{
//colorSelected = juce::Colours::darkgrey;
setColours(colorSelected, colorSelected.darker(), colorSelected);

}
GuessCircle::~GuessCircle()
{

}

void GuessCircle::paint(juce::Graphics& g)
{
    
    

    //circlePath.addEllipse(getWidth() / 6, getHeight() / 6, (int)(getWidth() * 2 / 3), (int)(getWidth() * 2 / 3));
    
}

void GuessCircle::resized()
{
    circlePath.clear();
    circlePath.addEllipse(5, 5, 30, 30);
    setShape(circlePath, true, true, true);

}

bool hitTest(int x, int y) override
{
    if (circlePath.contains(x, y, 1))
    {
        return true;
    }

    return false;
}

void setColor(juce::Colour color)
{
    colorSelected = color;

}

private:
//==============================================================================
juce::Path circlePath;

juce::Colour colorSelected;

JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR(GuessCircle)

};

And here’s the test code I’m using to call it:

class SolutionFrame : public juce::Component
{
public:
//==============================================================================
SolutionFrame::SolutionFrame()
:test1(“test1”, juce::Colours::darkgrey, juce::Colours::darkgrey, juce::Colours::darkgrey)
{
addAndMakeVisible(sTitle);
addAndMakeVisible(sContents);

    addAndMakeVisible(test1);
}

SolutionFrame::~SolutionFrame()
{
}

void SolutionFrame::paint(juce::Graphics& g)
{
    

}

void SolutionFrame::resized()
{
    //Set bounds of children
    sTitle.setBounds(0, 0, getWidth(), getHeight() / 4);
    sContents.setBounds(0, getHeight() / 4, getWidth(), (int)(getHeight() * 3 / 4));
    
    test1.setAlpha(1);
    test1.setColours(juce::Colours::darkgrey, juce::Colours::darkgrey, juce::Colours::darkgrey);
    test1.setAlwaysOnTop(true);
    test1.setBounds(getWidth() / 1.2, getHeight() / 1.5, 40, 40);
    testPath.clear();
    testPath.addEllipse(getWidth() / 1.2, getHeight() / 1.5, 40, 40);
    test1.setShape(testPath, false, false, true);
    
}

private:
//==============================================================================
SolutionTitle sTitle;
SolutionContents sContents;

GuessCircle test1;
juce::Path testPath;


JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR(SolutionFrame)

};

I know there’s some duplication in terms of setting the shape, I was trying it in both places to see if that was the problem.

You’ve overridden the paint() method but it’s empty so no graphics will be drawn.

You either need to write some code to draw the button, or simply remove the paint() method from your derived class to let the base class handle the painting.

I was right, that was painfully simple, thank you so much! Still have so much to learn.