How to hide component before it shows at startup?


#1

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?


#3

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.


#4

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.


#5

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


#6

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
}

#7

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