Skip to content

Commit e05cb86

Browse files
authored
Merge pull request #6485 from 424ever/textbox-drag-crash
Fix crash when dragging in a text box while a key is held down
2 parents 0a16e77 + 635ce03 commit e05cb86

File tree

2 files changed

+35
-0
lines changed

2 files changed

+35
-0
lines changed

osu.Framework.Tests/Visual/UserInterface/TestSceneTextBox.cs

+34
Original file line numberDiff line numberDiff line change
@@ -800,6 +800,40 @@ public void TestSetTextSelection()
800800
AddAssert("nothing selected", () => textBox.SelectedText == string.Empty);
801801
}
802802

803+
[Test]
804+
public void TestTextChangedDuringDoubleClickDrag()
805+
{
806+
InsertableTextBox textBox = null;
807+
808+
AddStep("add textbox", () =>
809+
{
810+
textBoxes.Add(textBox = new InsertableTextBox
811+
{
812+
Size = new Vector2(300, 40),
813+
Text = "initial text",
814+
});
815+
});
816+
817+
AddStep("click on textbox", () =>
818+
{
819+
InputManager.MoveMouseTo(textBox);
820+
InputManager.Click(MouseButton.Left);
821+
});
822+
823+
AddStep("set text", () => textBox.Text = "aaaaaaaaaaaaaaaaaaaa");
824+
825+
AddStep("select word", () =>
826+
{
827+
InputManager.Click(MouseButton.Left);
828+
InputManager.PressButton(MouseButton.Left);
829+
});
830+
831+
AddStep("insert text", () => textBox.InsertString("a"));
832+
AddAssert("text overwritten", () => textBox.Text == "a");
833+
AddStep("start drag", () => InputManager.MoveMouseTo(textBox, new Vector2(-50, 0)));
834+
AddStep("end drag", () => InputManager.ReleaseButton(MouseButton.Left));
835+
}
836+
803837
[Test]
804838
public void TestSelectAll()
805839
{

osu.Framework/Graphics/UserInterface/TextBox.cs

+1
Original file line numberDiff line numberDiff line change
@@ -773,6 +773,7 @@ private string removeCharacters(int number = 1)
773773
TextFlow.ChangeChildDepth(TextFlow[i], getDepthForCharacterIndex(i));
774774

775775
selectionStart = selectionEnd = removeStart;
776+
doubleClickWord = null;
776777

777778
endTextChange(beganChange);
778779
cursorAndLayout.Invalidate();

0 commit comments

Comments
 (0)