Просмотр исходного кода

Merge pull request #244 from TheCosmotect/copycut

Added ability to cut and copy the current line in UITextInput without selecting
Ivan Safrin 12 лет назад
Родитель
Сommit
9cf2267461
1 измененных файлов с 14 добавлено и 3 удалено
  1. 14 3
      Modules/Contents/UI/Source/PolyUITextInput.cpp

+ 14 - 3
Modules/Contents/UI/Source/PolyUITextInput.cpp

@@ -856,7 +856,7 @@ void UITextInput::setCaretToMouse(Number x, Number y) {
 		
 	caretPosition = newCaretPosition;	
 		
-	updateCaretPosition();	
+	updateCaretPosition();
 }
 
 void UITextInput::removeLines(unsigned int startIndex, unsigned int endIndex) {
@@ -1039,13 +1039,24 @@ void UITextInput::Cut() {
 	Copy();
 	if(hasSelection) {
 		deleteSelection();
-	}	
+	} else if (getLineText(lineOffset) != "") {
+        if (!multiLine) { setText(""); }
+        else {
+            removeLines(lineOffset, lineOffset+1);
+            caretPosition = 0;
+            updateCaretPosition();
+        }
+    }
 }
 
 void UITextInput::Copy() {
 	if(hasSelection) {
 		CoreServices::getInstance()->getCore()->copyStringToClipboard(getSelectionText());
-	}
+	} else {
+        if (getLineText(lineOffset) != "") {
+            CoreServices::getInstance()->getCore()->copyStringToClipboard(getLineText(lineOffset));
+        }
+    }
 }
 
 void UITextInput::Paste() {