Browse Source

Applied LineEdit patch from Magic.Lixin.

Lasse Öörni 13 years ago
parent
commit
86887ed0c2
1 changed files with 12 additions and 0 deletions
  1. 12 0
      Engine/UI/LineEdit.cpp

+ 12 - 0
Engine/UI/LineEdit.cpp

@@ -214,6 +214,18 @@ void LineEdit::OnKey(int key, int buttons, int qualifiers)
             const String& clipBoard = GetSubsystem<UI>()->GetClipBoardText();
             if (!clipBoard.Empty())
             {
+                // Remove selected text first
+                if(text_->GetSelectionLength() > 0)
+                {
+                    unsigned start = text_->GetSelectionStart();
+                    unsigned length = text_->GetSelectionLength();
+                    if (start + length < line_.LengthUTF8())
+                        line_ = line_.SubstringUTF8(0, start) + line_.SubstringUTF8(start + length);
+                    else
+                        line_ = line_.SubstringUTF8(0, start);
+                    text_->ClearSelection();
+                    cursorPosition_ = start;
+                }
                 if (cursorPosition_ < line_.LengthUTF8())
                     line_ = line_.SubstringUTF8(0, cursorPosition_) + clipBoard + line_.SubstringUTF8(cursorPosition_);
                 else