Hi,
I am designing a standalone JUCE application. I’ve got a problem with calling one MainComponent function, and I want to explain it on the easier example.
I create the new JUCE project for GUI application. In MainComponent class, I add the Label, make it visible on the app window, and write the function setLabelText(), which sets the text “Lalala” on this label.
Then I create the new class for GUI object called e.g. PressButton. This class contains only the 2-state TextButton (on/off). The object of this class is created in the MainComponent.h file, and its parameters are set in MainComponent constructor and MainComponent::resize() function. Of course the PressButton class also have the lambda function “Update Toggle state”. The MainComponent class and the PressButton class don’t inherit themself in any way, simply PressButton class is included into the MainComponent.h file, and in this file the object of this class is created.
My question is: How can I call the setLabelText() function (from MainComponent class) from the lambda function of the PressButton class? (so when I press the button, the text will appear). I try to include MainComponent.h and PressButton.h in several ways, but Visual Studio 2019 doesn’t compile the program. I know one trick - include the PressButton.h file in MainComponent.cpp file, and create the e.g. dynamic object of Press Button class for example in MainComponent constructor, but in the main source code I need the access to this object from any function of MainComponent (in this case - I’ve got this access only in MainComponent constructor). Any other ideas?
Thanks in advance,
Kamil