diff --git a/modules/juce_gui_basics/widgets/juce_TextEditor.cpp b/modules/juce_gui_basics/widgets/juce_TextEditor.cpp index c36fced547..387e283e70 100644 --- a/modules/juce_gui_basics/widgets/juce_TextEditor.cpp +++ b/modules/juce_gui_basics/widgets/juce_TextEditor.cpp @@ -1498,7 +1498,9 @@ RectangleList TextEditor::getTextBounds (Range textRange) } } - boundingBox.offsetAll (getLeftIndent(), roundToInt ((float) getTopIndent() + yOffset)); + boundingBox.offsetAll (getLeftIndent() - viewport->getViewPositionX(), + roundToInt ((float) getTopIndent() + yOffset) - viewport->getViewPositionY()); + return boundingBox; } diff --git a/modules/juce_gui_basics/widgets/juce_TextEditor.h b/modules/juce_gui_basics/widgets/juce_TextEditor.h index 2aaec63a9a..5e973d3adf 100644 --- a/modules/juce_gui_basics/widgets/juce_TextEditor.h +++ b/modules/juce_gui_basics/widgets/juce_TextEditor.h @@ -537,6 +537,9 @@ public: /** Returns the bounding box for a range of text in the editor. As the range may span multiple lines, this method returns a RectangleList. + + The bounds are relative to the component's top-left and may extend beyond the bounds + of the component if the text is long and word wrapping is disabled. */ RectangleList getTextBounds (Range textRange);