From 8ee13b78baab48d7bb48404fc44af52f16af1e28 Mon Sep 17 00:00:00 2001 From: ed Date: Mon, 16 Nov 2020 16:10:13 +0000 Subject: [PATCH] Avoid drawing TextEditor "empty" text when it isn't visible --- modules/juce_gui_basics/widgets/juce_TextEditor.cpp | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/modules/juce_gui_basics/widgets/juce_TextEditor.cpp b/modules/juce_gui_basics/widgets/juce_TextEditor.cpp index 0b21f75ca1..23dc74f43e 100644 --- a/modules/juce_gui_basics/widgets/juce_TextEditor.cpp +++ b/modules/juce_gui_basics/widgets/juce_TextEditor.cpp @@ -1730,10 +1730,13 @@ void TextEditor::paintOverChildren (Graphics& g) g.setColour (colourForTextWhenEmpty); g.setFont (getFont()); - g.drawText (textToShowWhenEmpty, - leftIndent, topIndent, - viewport->getWidth() - leftIndent, getHeight() - topIndent, - justification, true); + Rectangle textBounds (leftIndent, + topIndent, + viewport->getWidth() - leftIndent, + getHeight() - topIndent); + + if (! textBounds.isEmpty()) + g.drawText (textToShowWhenEmpty, textBounds, justification, true); } getLookAndFeel().drawTextEditorOutline (g, getWidth(), getHeight(), *this);