1
0
mirror of https://github.com/ppy/osu.git synced 2024-12-16 21:02:55 +08:00

Merge pull request #29044 from frenzibyte/fix-drag-overwritten-by-focus

Fix dragging number boxes no longer working correctly
This commit is contained in:
Dan Balasescu 2024-07-25 08:36:39 +09:00 committed by GitHub
commit d057bee4fb
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 20 additions and 1 deletions

View File

@ -76,6 +76,24 @@ namespace osu.Game.Tests.Visual.UserInterface
InputManager.Click(MouseButton.Left);
});
AddAssert("text selected", () => numberBoxes.First().SelectedText == "987654321");
AddStep("click away", () =>
{
InputManager.MoveMouseTo(Vector2.Zero);
InputManager.Click(MouseButton.Left);
});
Drawable textContainer = null!;
AddStep("move mouse to end of text", () =>
{
textContainer = numberBoxes.First().ChildrenOfType<Container>().ElementAt(1);
InputManager.MoveMouseTo(textContainer.ScreenSpaceDrawQuad.TopRight);
});
AddStep("hold mouse", () => InputManager.PressButton(MouseButton.Left));
AddStep("drag to half", () => InputManager.MoveMouseTo(textContainer.ScreenSpaceDrawQuad.BottomRight - new Vector2(textContainer.ScreenSpaceDrawQuad.Width / 2 + 1f, 0)));
AddStep("release mouse", () => InputManager.ReleaseButton(MouseButton.Left));
AddAssert("half text selected", () => numberBoxes.First().SelectedText == "54321");
}
private void clearTextboxes(IEnumerable<OsuTextBox> textBoxes) => AddStep("clear textbox", () => textBoxes.ForEach(textBox => textBox.Text = null));

View File

@ -261,7 +261,8 @@ namespace osu.Game.Graphics.UserInterface
base.OnFocus(e);
if (SelectAllOnFocus)
// we may become focused from an ongoing drag operation, we don't want to overwrite selection in that case.
if (SelectAllOnFocus && string.IsNullOrEmpty(SelectedText))
SelectAll();
}