From 0f9e59c826af914fd864465d6368f59b4b5d8bce Mon Sep 17 00:00:00 2001 From: Bruno Van de Velde Date: Fri, 6 Oct 2017 19:44:23 +0200 Subject: [PATCH] :beetle: TextBox::getSelectedText sometimes contained newlines that were not in the original text (they where added internally for word wrapping) --- src/TGUI/Widgets/TextBox.cpp | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/TGUI/Widgets/TextBox.cpp b/src/TGUI/Widgets/TextBox.cpp index 799c36f0..ed8eff72 100644 --- a/src/TGUI/Widgets/TextBox.cpp +++ b/src/TGUI/Widgets/TextBox.cpp @@ -149,7 +149,11 @@ namespace tgui sf::String TextBox::getSelectedText() const { - return m_textSelection1.getString() + m_textSelection2.getString(); + auto pos = findTextSelectionPositions(); + if (pos.first > pos.second) + std::swap(pos.first, pos.second); + + return m_text.substring(pos.first, pos.second - pos.first); } /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////