Trouble with simple ShapeButton


I’m not sure what I’m missing here, but my ShapeButton does not want to appear.
Here’s the code:

// initialisation
              recordButton ("Record",

        Path recordPath;
        float shapeButtonSize = getHeight()/12;
        recordPath.addEllipse(0, 0, shapeButtonSize, shapeButtonSize);
        recordButton.setShape(recordPath, false, true, false);
        recordButton.setBounds (0, 0, 50, 50);
        addAndMakeVisible (&recordButton);

I’ve tested with g.fillPath(recordPath) in my paint method and it works there… any ideas?


Where in your project are you running this code from? If it’s in the constructor of a parent Component you’ll want to make sure that you’ve given it a size before with a call to setSize()



Found it, there was a subtle clue there…

float shapeButtonSize = getHeight()/12;

getHeight returns 0 as the component does not have a height yet, so yes I need to set this in resized() instead of the constructor!