Toolbar basics


#1

Juce Friends,

I am having trouble with the basics of creating a toolbar…What are the very basic elements that I need to have a toolbar displayed horizontally within my component that I create? I’ve studied the Widgets demo source code and taken a look at the api documentation, but the basics of creating a toolbar have still eluded me.

What I have within my component cpp is:
addAndMakeVisible (toolbar = new Toolbar());

And within my header file I have:
Toolbar* toolbar;
within the private member declaration.

This allows the program to compile but at runtime the toolbar doesn’t appear. I know that you have to add factory default items for the icons, but right now I would just like the toolbar to basically appear. What are the other minimal elements that I need to specify in order to have a toolbar appear at the top of a component and run horizontally across?

Any help greatly appreciated. Thank you in advance.


#2

You also have to put it in the right place, just like any other component… You’ve done that, right?


#3

Yes, presumably…But maybe I wouldn’t be having this problem if I knew for sure :slight_smile:

The toolbar add is within the component constructor, like so:

AuthComponent::AuthComponent ()
: textLoginButton (0),
textEditorUsername (0),
textEditorPassword (0),
labelCredRequest (0),
userAuthLabel (0),
pwdAuthLabel (0),
toolbar (0)
{

addAndMakeVisible (toolbar = new Toolbar());

// rest of constructor

}


#4

Sorry - that’s not what I meant - I meant you need to setBounds() on it to put it in the right UI location.


#5

Thank you.