How to hide component before it shows at startup?

It appears that the order we initially added our component views affects what shows when our plug-in windows appear initially. We want certain views to be hidden initially, but since JUCE puts the “addAndMakeVisible” call in the code automatically, and we have no control of the order in which they are added, I don’t see a way to make those views hidden, so that they don’t show up for an instant after creation before we get a chance to hide them. How do we do that?

Ok, I see how to do it in code. I can call addChildComponent() instead of addAndMakeVisible(), apparently. That skips the call to make it visible, which is what I need. Exposing the visible property in Projucer would be nice, though, I think.

1 Like

Don’t use the ProJucer component editor to make your layout. It’s not recommended by the Juce team. Thats the only place addAndMakeVisible is added automatically.

If you wanna hide components just do: yourComponent.setVisible(false) (or true if you wanna show it).

1 Like

I agree with johngalt91 and if you have more than one component you can make your own fonction like this:

//in the init
addAndMakeTextButton(myTextButton, false);
// the fonction
void addAndMakeTextButton (&TextButton button, bool visible)
{
addAndMakeVisible(button);
button.setVisible(visible);
//Add all the init parameters you want
}

Thanks, guys! I now add it via code, using addChildComponent instead of addAndMakeVisible. Then I make it visible if and when I need to.

@HowardAntares can you show me please how you did this?