Hello, I’m learning how to use tabbed component. I saw an example of tabbed component in an article, which helped me a lot, but there was a problem that bothered me and I didn’t know how to solve it. I need to use the array values I defined in maincontentcomponent to set the setselectedId() of combobox defined in sliderholder(). However, I couldn’t get the array of maincontentcomponent in sliderholder(). How can I solve this problem?
This is my example
class MainContentComponent : public Component
{
public:
//==============================================================================
MainContentComponent() : tabs (TabbedButtonBar::Orientation::TabsAtTop)
{
addAndMakeVisible (tabs);
tabs.addTab ("Blank", Colours::hotpink, new Component(), true);
tabs.addTab ("Slider", findColour(ResizableWindow::ColourIds::backgroundColourId), new SliderHolder(), true);
setSize (600, 400);
}
~MainContentComponent() {}
void paint (Graphics&) override {}
void resized() override
{
tabs.setBounds (getLocalBounds().reduced (20));
}
private:
TabbedComponent tabs;
char Data1[6]{1,2,3,4,5,6};
struct SliderHolder : public Component
{
SliderHolder()
{
addAndMakeVisible (slider);
addAndMakeVisible(Fad_CCbox);
for (int i = 0; i < 128; ++i)
{
Fad_CCbox.addItem((String)i, i + 1);
}
}
void SliderHolder ::visibilityChanged()
{
if (isVisible() )
{
// How to call the data of array defined in maincontentcomponent in setselectedid() of drop-down list?
//MainContentComponent *msg;
//In this way, the sub call cannot get the data of maincontentcomponent
//Fad_CCbox.setSelectedId(msg->Data[0]);
//Fad_Chbox.setSelectedId(msg->Data[1]);
}
}
void resized() override
{
slider.centreWithSize (getWidth() - 40, 150);
}
ComboBox Fad_CCbox;
Slider slider;
};
//==============================================================================
JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (MainContentComponent)
};