1
0
mirror of https://github.com/ppy/osu.git synced 2026-06-10 00:56:34 +08:00

Allow specifying LengthLimit on form text boxes (#37927)

Will come in handy for stuff like the multiplayer match creation screen.


[Screencast_20260527_162854.webm](https://github.com/user-attachments/assets/03d36104-da6c-4cdf-a1ad-439ddfd2036a)
This commit is contained in:
Krzysztof Gutkowski
2026-06-09 13:00:59 +02:00
committed by GitHub
Unverified
parent 5a7ea1f9d5
commit b7848599cd
2 changed files with 13 additions and 0 deletions
@@ -67,6 +67,13 @@ namespace osu.Game.Tests.Visual.UserInterface
TabbableContentContainer = this,
},
new FormTextBox
{
Caption = "Length limited text",
PlaceholderText = "I can only hold 10 characters!",
LengthLimit = 10,
TabbableContentContainer = this,
},
new FormTextBox
{
Caption = "Artist",
HintText = "Poot artist here!",
@@ -77,6 +77,11 @@ namespace osu.Game.Graphics.UserInterfaceV2
/// </summary>
public LocalisableString PlaceholderText { get; init; }
/// <summary>
/// Maximum allowed length of text.
/// </summary>
public int? LengthLimit { get; init; }
private FormControlBackground background = null!;
private Box flashLayer = null!;
private InnerTextBox textBox = null!;
@@ -120,6 +125,7 @@ namespace osu.Game.Graphics.UserInterfaceV2
t.RelativeSizeAxes = Axes.X;
t.Width = 1;
t.PlaceholderText = PlaceholderText;
t.LengthLimit = LengthLimit;
t.Current = Current;
t.CommitOnFocusLost = true;
t.OnCommit += (textBox, newText) =>