Browse Source

On LineEdit move around the borders of current selection.

reattiva 12 years ago
parent
commit
2ac0d8955e
1 changed files with 8 additions and 4 deletions
  1. 8 4
      Source/Engine/UI/LineEdit.cpp

+ 8 - 4
Source/Engine/UI/LineEdit.cpp

@@ -249,8 +249,6 @@ void LineEdit::OnKey(int key, int buttons, int qualifiers)
         // Fallthru
 
     case KEY_LEFT:
-        if (!(qualifiers & QUAL_SHIFT))
-            text_->ClearSelection();
         if (cursorMovable_ && cursorPosition_ > 0)
         {
             if (textSelectable_ && qualifiers & QUAL_SHIFT && !text_->GetSelectionLength())
@@ -258,6 +256,8 @@ void LineEdit::OnKey(int key, int buttons, int qualifiers)
 
             if (qualifiers & QUAL_CTRL)
                 cursorPosition_ = 0;
+            else if (text_->GetSelectionLength() && !(qualifiers & QUAL_SHIFT))
+                cursorPosition_ = text_->GetSelectionStart();
             else
                 --cursorPosition_;
             cursorMoved = true;
@@ -272,6 +272,8 @@ void LineEdit::OnKey(int key, int buttons, int qualifiers)
                     text_->SetSelection(current, start - current);
             }
         }
+        if (!(qualifiers & QUAL_SHIFT))
+            text_->ClearSelection();
         break;
 
     case KEY_END:
@@ -279,8 +281,6 @@ void LineEdit::OnKey(int key, int buttons, int qualifiers)
         // Fallthru
 
     case KEY_RIGHT:
-        if (!(qualifiers & QUAL_SHIFT))
-            text_->ClearSelection();
         if (cursorMovable_ && cursorPosition_ < line_.LengthUTF8())
         {
             if (textSelectable_ && qualifiers & QUAL_SHIFT && !text_->GetSelectionLength())
@@ -288,6 +288,8 @@ void LineEdit::OnKey(int key, int buttons, int qualifiers)
 
             if (qualifiers & QUAL_CTRL)
                 cursorPosition_ = line_.LengthUTF8();
+            else if (text_->GetSelectionLength() && !(qualifiers & QUAL_SHIFT))
+                cursorPosition_ = text_->GetSelectionStart() + text_->GetSelectionLength();
             else
                 ++cursorPosition_;
             cursorMoved = true;
@@ -302,6 +304,8 @@ void LineEdit::OnKey(int key, int buttons, int qualifiers)
                     text_->SetSelection(current, start - current);
             }
         }
+        if (!(qualifiers & QUAL_SHIFT))
+            text_->ClearSelection();
         break;
 
     case KEY_DELETE: