Hi,
I’ve a chicken and egg issue with those method. I’ve overload a label, and in the editorAboutToBeHidden() method, I’m formatting the text of the label, thus calling Label::setText.
But, since the editor is still no hidden in there, it’s calling editorA…hidden() again, and overflow the stack.
I’ve tried to change the text of the TextEditor component, but it’s ignored when returning from the editorAb…dden() method.
I can add an asynchronous change, but it’s a PITA for such a simple operation.
So, I think the code in juce for juce_Label.cpp should read instead:
void Label::setText (const String& newText,
const bool broadcastChangeMessage)
{
if (isBeingEdited())
hideEditor (true);
if (lastTextValue != newText)
{
and
void Label::hideEditor (const bool discardCurrentEditorContents)
{
if (editor != 0)
{
WeakReference<Component> deletionChecker (this);
ScopedPointer<TextEditor> temporaryEditor(editor.release());
editorAboutToBeHidden (temporaryEditor);
const bool changed = (! discardCurrentEditorContents)
&& updateFromTextEditorContents(temporaryEditor);
temporaryEditor = 0;
repaint();
and
void Label::textEditorReturnKeyPressed (TextEditor& ed)
{
if (editor != 0)
{
jassert (&ed == editor);
(void) ed;
const bool changed = updateFromTextEditorContents(editor);
and
bool Label::updateFromTextEditorContents(TextEditor * _editor)
{
jassert (_editor != 0);
const String newText (_editor->getText());
if (textValue.toString() != newText)
{