From ed0c032a01969bf04d2ecfb94407f6e266567ad1 Mon Sep 17 00:00:00 2001 From: luigisambuy Date: Mon, 5 Sep 2016 11:50:18 +0100 Subject: [PATCH] Added a styleChanged flag to enable setText() to take effect after setColor() --- modules/juce_gui_basics/widgets/juce_TextEditor.cpp | 6 +++++- modules/juce_gui_basics/widgets/juce_TextEditor.h | 1 + 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/modules/juce_gui_basics/widgets/juce_TextEditor.cpp b/modules/juce_gui_basics/widgets/juce_TextEditor.cpp index 41b8f4d825..73b04297fe 100644 --- a/modules/juce_gui_basics/widgets/juce_TextEditor.cpp +++ b/modules/juce_gui_basics/widgets/juce_TextEditor.cpp @@ -915,6 +915,7 @@ TextEditor::TextEditor (const String& name, menuActive (false), valueTextNeedsUpdating (false), consumeEscAndReturnKeys (true), + styleChanged (false), leftIndent (4), topIndent (4), lastTransactionTime (0), @@ -1080,6 +1081,7 @@ void TextEditor::colourChanged() { setOpaque (findColour (backgroundColourId).isOpaque()); repaint(); + styleChanged = true; } void TextEditor::lookAndFeelChanged() @@ -1186,7 +1188,7 @@ void TextEditor::setText (const String& newText, { const int newLength = newText.length(); - if (newLength != getTotalNumChars() || getText() != newText) + if (newLength != getTotalNumChars() || getText() != newText || styleChanged) { textValue = newText; @@ -1212,6 +1214,8 @@ void TextEditor::setText (const String& newText, scrollToMakeSureCursorIsVisible(); undoManager.clearUndoHistory(); + styleChanged = false; + repaint(); } } diff --git a/modules/juce_gui_basics/widgets/juce_TextEditor.h b/modules/juce_gui_basics/widgets/juce_TextEditor.h index 6d2bd5fb19..573909d45d 100644 --- a/modules/juce_gui_basics/widgets/juce_TextEditor.h +++ b/modules/juce_gui_basics/widgets/juce_TextEditor.h @@ -684,6 +684,7 @@ private: bool menuActive; bool valueTextNeedsUpdating; bool consumeEscAndReturnKeys; + bool styleChanged; UndoManager undoManager; ScopedPointer caret;