I Have a simple button component which is using paintButton, this is what jucer created as below called buttontools.h
[code]#ifndef BUTTONTOOLS_H
#define BUTTONTOOLS_H
#include <juce.h>
//==============================================================================
/**
An image based button class
*/
class OnOffButton : public Button
{
public:
//==============================================================================
/** Constructor */
OnOffButton(const String& buttonName);
/** Destructor */
~OnOffButton();
/** @internal */
void paintButton (Graphics& g, bool isMouseOverButton, bool isButtonDown);
private:
//==============================================================================
// (prevent copy constructor and operator= being generated..)
OnOffButton (const OnOffButton&);
const OnOffButton& operator= (const OnOffButton&);
};
OnOffButton::OnOffButton (const String& buttonName)
: Button(buttonName)
{
setSize(50,50);
}
OnOffButton::~OnOffButton()
{
}
void OnOffButton::paintButton (Graphics& g, bool isMouseOverButton, bool isButtonDown)
{
if (getToggleState())
{
g.setColour (Colour (Colours::red));
g.fillEllipse (4.0f, 4.0f, 20.0f, 20.0f);
}
else
{
g.setColour (Colour (Colours::blue));
g.fillEllipse (4.0f, 4.0f, 20.0f, 20.0f);
}
}
#endif[/code]
Im using this like below, its suppose to toggle like and onoff button, works inside juce but does not toggle here!!!, however id does show up, am I missing something? Should be acting like a simple switch
[code]#include “…/…/juce.h”
#include “buttontools.h”
//==============================================================================
/** This is the component that sits inside the “hello world” window, filling its
content area. In this example, we’ll just write “hello world” inside it.
*/
class HelloWorldContentComponent : public Component
{
OnOffButton* myonoff;
public:
HelloWorldContentComponent()
{
//ONOFF SWITCH
addAndMakeVisible (myonoff = new OnOffButton (T(“OnOff”)));//Do This First!
myonoff->setBounds(30,60,26,26);
}
~HelloWorldContentComponent()
{
}
void paint (Graphics& g)
{
}
};[/code]