Hello,
I have a very basic button here and all I,m trying to do is change the color of the ellipse based on isButtonDown and isMouseOver. All this worked fine, up until I added the mouseDown method wich causes the isButtonDown color-change to never get hit. Is it getting hijacked by mouseDown. I swear I had this working in previouse projects.
I also made the same type of button in the Jucer, when previewing in the Jucer program with the “callback methods to generate” checked on for mouseDown and mouseDrag it works fine. As soon as I put it in to my project it stops working.
This is probably very simple and I’m just missing something.
class SoundDOT : public Button
{
public:
SoundDOT(const String& name,int numLabel)
: Button(name),
dotSize(25.0f),
dotX(0),
dotY(0),
numberLabel(String(numLabel))
{
setSize (dotSize, dotSize);
constrainer.setMinimumOnscreenAmounts((int)dotSize,(int)dotSize,(int)dotSize,(int)dotSize);
}
~SoundDOT()
{
deleteAllChildren();
}
void resized()
{
setBounds(dotX,dotY,(int)dotSize,(int)dotSize);
}
void paintButton(Graphics& g, bool isMouseOverButton, bool isButtonDown)
{
float strokeClip = 20.0f;
if(isButtonDown)
{
g.setColour (Colours::red);
}
else if(isMouseOverButton)
{
g.setColour (Colour (0xffcee208).brighter());
}
else
{
g.setColour (Colour (0xffcee208));
}
//Ellipse
g.fillEllipse (0, 0, (float)getWidth(), (float)getHeight());
g.setColour (Colours::white);
g.drawEllipse ((dotSize / strokeClip)/2,
(dotSize / strokeClip)/2,
(float)getWidth() - (dotSize / strokeClip),
(float)getHeight() - (dotSize / strokeClip),
dotSize / strokeClip);
//Text
g.setColour(Colours::black);
g.setFont (Font (dotSize/1.5f, Font::plain));
g.drawText(numberLabel,0,0,getWidth(), getHeight(), Justification::centred, true);
}
void mouseDown (const MouseEvent& e)
{
toFront(true);
dragger.startDraggingComponent (this, &constrainer);
}
void mouseDrag (const MouseEvent& e)
{
dragger.dragComponent (this, e);
}
private:
ComponentDragger dragger;
ComponentBoundsConstrainer constrainer;
float dotSize;
int dotX, dotY;
String numberLabel;
};
Thanks
