Browse Source

Fix text widget editing after cut operation

Michael Ragazzon 3 years ago
parent
commit
6af110796d
1 changed files with 4 additions and 5 deletions
  1. 4 5
      Source/Core/Elements/WidgetTextInput.cpp

+ 4 - 5
Source/Core/Elements/WidgetTextInput.cpp

@@ -413,6 +413,7 @@ void WidgetTextInput::ProcessEvent(Event& event)
 			{
 			{
 				CopySelection();
 				CopySelection();
 				DeleteSelection();
 				DeleteSelection();
+				DispatchChangeEvent();
 				ShowCursor(true);
 				ShowCursor(true);
 			}
 			}
 		}
 		}
@@ -562,8 +563,6 @@ bool WidgetTextInput::DeleteCharacters(CursorMovement direction)
 		DeleteSelection();
 		DeleteSelection();
 		DispatchChangeEvent();
 		DispatchChangeEvent();
 
 
-		UpdateSelection(false);
-
 		return true;
 		return true;
 	}
 	}
 
 
@@ -1227,9 +1226,9 @@ void WidgetTextInput::DeleteSelection()
 	if (selection_length > 0)
 	if (selection_length > 0)
 	{
 	{
 		String new_value = GetAttributeValue();
 		String new_value = GetAttributeValue();
-		const size_t selection_end = std::min(size_t(selection_begin_index + selection_length), (size_t)new_value.size()) ;
+		const size_t selection_begin = std::min((size_t)selection_begin_index, (size_t)new_value.size());
+		new_value.erase(selection_begin, (size_t)selection_length);
 		
 		
-		new_value = new_value.substr(0, selection_begin_index) + new_value.substr(selection_end);
 		GetElement()->SetAttribute("value", new_value);
 		GetElement()->SetAttribute("value", new_value);
 
 
 		// Move the cursor to the beginning of the old selection.
 		// Move the cursor to the beginning of the old selection.
@@ -1238,7 +1237,7 @@ void WidgetTextInput::DeleteSelection()
 		UpdateCursorPosition(true);
 		UpdateCursorPosition(true);
 
 
 		// Erase our record of the selection.
 		// Erase our record of the selection.
-		ClearSelection();
+		UpdateSelection(false);
 	}
 	}
 }
 }