瀏覽代碼

Implement CTRL+right move (go to end of word)

Marc Plano-Lesay 12 年之前
父節點
當前提交
01e01a197b
共有 1 個文件被更改,包括 10 次插入1 次删除
  1. 10 1
      gameplay/src/TextBox.cpp

+ 10 - 1
gameplay/src/TextBox.cpp

@@ -202,7 +202,16 @@ bool TextBox::keyEvent(Keyboard::KeyEvent evt, int key)
 
                     int textIndex = font->getIndexAtLocation(displayedText.c_str(), _textBounds, fontSize, _caretLocation, &_caretLocation,
                         textAlignment, true, rightToLeft);
-                    font->getLocationAtIndex(displayedText.c_str(), _textBounds, fontSize, &_caretLocation, textIndex + 1,
+                    if (_ctrlPressed)
+                    {
+                        std::string::const_iterator it = std::find_if(displayedText.begin() + (textIndex + 1), displayedText.end(), space);
+                        textIndex = std::distance(displayedText.begin(), it);
+                    }
+                    else
+                    {
+                        ++textIndex;
+                    }
+                    font->getLocationAtIndex(displayedText.c_str(), _textBounds, fontSize, &_caretLocation, textIndex,
                         textAlignment, true, rightToLeft);
                     _dirty = true;
                     break;