I am writing regarding an subcomponent drawing update problem I have. I am creating a minimalist GUI application. The aim is to print continues values on a Label component. I have now taken following steps.
1. I have created a GUI sub component class called CustomComponent in the Introjucer. The Class introduces a Label called intLabel
2. I have created a reference to the sub class in MainComponent and made the sub component visible
3. in the CustomComponent I have created a method called updateLabel() which embodies intLabel-setText() method as follows
The setText() within updateLabel() method works as expected when called through CustomComponent constructor. That is, intLabel’s field reveives values and they get printed as expected.
Now the problem is following. If the updateLabel() method is called through another class the text field does not update. However, sent values are stored in the intLabel. I have checked this with getText() method as follows
intLabel->getText());
I am asking what should I do differently in order to make the intLabel update visually? Your help is much appreciated.
I concidered that also bazrush - I added repaint() calls before and after the setText() call. However, the resulting is still the same - no update in the text field.
Let me eloborate my application logic a bit. Now I am drawing a button on the MainComponent and a Label on the CustomComponent.
Further, my application logic requires a click of the button before values are sent via updateLabel() which writes values via intLabel->setText().
Could the specific update problem exist because the button on the MainComponent is clicked first and does this influence CustomComponet behaviour somehow?
That would be classical mistake having two objects and cross referencing them. However, that should not be source of an error this time.
The DBG-message gets printed properly. One think comes to my mind. Could it be that the screen does not update beacause I trigger the updateLabel() through an external application? That is I send OSC messages via PureData patch. I could debug this by adding a button on a Juce application and calling updateLabel() method through that. What do you think?
Edit on Friday 12. 2014, 4:45 PM
Adding a slider to the CustomComponent class works as expected. That is, when sending slider values to updateLabel() method the intLabel updates it's values.
setIntTextField(slider->getValue());
Summarizing this. I need to find answer to the question how Juce Label Component listens incoming messages. In particular, in my case how to make the intLabel to update it's GUI when called via external input device.
Well if setIntTextField is being called with an integer you'll get the same result no matter what you call it with. How long is the rest of the code? Can you make a simple example that shows the failure?
The aim of the program is to print values on a label component. This works as expected when values are sent via slider component. However, the problem is that the label values do not get printed visually when they are tgriggered via an external application sending osc messages.
On a practical level ReceiveOSC class receives osc messages and sends them forward by calling the CustomComponent class method called setFloatTextField(). The label within method stores the values but they are not displayed.
Would be great if someone coud point me towards right direction.
I'll have a quick peek tomorrow - but might be Wednesday before I can have a proper look! But if no-one else gets back to you I'll definitely get to it :)
There's a separate problem you might have with having two threads - but that's minor at this stage and it'll work most of the time. The main problem is you have two CustomComponents. One in MainContentComponent and the other inside ReceiveOSC.
There are a million solutions to this. You could pass a reference or pointer to the CustomComponent in to your ReceieveOSC function. You could make a custom listener callback, you could do something C++11 with a lambda. Or you could look at the various JUCE classes for passing messages around. Try AsyncUpdater and ChangeBroadcaster as starting points.
And for the inter-thread solution ScopedLock, or AbstractFIFO if you want more of a headache but don't want to use locks ..