Tuesday, January 18, 2005

JUCE - How to make a button

As I am currently starting to create an application with JUCE, I thought I post every now and then some things I find. Might turn out to be a little tutorial.

Today on the the first part :-) I give you THE TEXT BUTTON

// ToolTip does not work currently on Windows...
TextButton * button = new TextButton( T("Button"), Colours::lavender, Colours::teal, Colours::springgreen, T("tooltip") );

if( button )
{
// We only care about the height, as we call "fit text" for the width
button->setSize (100, 28);
button->changeWidthToFitText();
button->setTopLeftPosition(10,360);

// We need to add an Actionistener
// We can simply inherit this class from ActionListener
// and overwrite the actionListenerCallback()
button->addActionListener (this);

addAndMakeVisible( button ); // Voila, done!
}

No comments: