فهرست منبع

Added ability to cut and copy the current line in UITextInput without selecting

Ethan M 12 سال پیش
والد
کامیت
428490c1c9
1فایلهای تغییر یافته به همراه14 افزوده شده و 3 حذف شده
  1. 14 3
      Modules/Contents/UI/Source/PolyUITextInput.cpp

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

@@ -857,7 +857,7 @@ void UITextInput::setCaretToMouse(Number x, Number y) {
 		
 	caretPosition = newCaretPosition;	
 		
-	updateCaretPosition();	
+	updateCaretPosition();
 }
 
 void UITextInput::removeLines(unsigned int startIndex, unsigned int endIndex) {
@@ -1040,13 +1040,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() {