mirror of
https://github.com/ppy/osu.git
synced 2024-12-16 23:02:56 +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:
commit
d057bee4fb
@ -76,6 +76,24 @@ namespace osu.Game.Tests.Visual.UserInterface
|
|||||||
InputManager.Click(MouseButton.Left);
|
InputManager.Click(MouseButton.Left);
|
||||||
});
|
});
|
||||||
AddAssert("text selected", () => numberBoxes.First().SelectedText == "987654321");
|
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));
|
private void clearTextboxes(IEnumerable<OsuTextBox> textBoxes) => AddStep("clear textbox", () => textBoxes.ForEach(textBox => textBox.Text = null));
|
||||||
|
@ -261,7 +261,8 @@ namespace osu.Game.Graphics.UserInterface
|
|||||||
|
|
||||||
base.OnFocus(e);
|
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();
|
SelectAll();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user