diff --git a/osu.Game.Tests/Visual/UserInterface/TestSceneFormControls.cs b/osu.Game.Tests/Visual/UserInterface/TestSceneFormControls.cs index 5d4ef422a4..2463ab6741 100644 --- a/osu.Game.Tests/Visual/UserInterface/TestSceneFormControls.cs +++ b/osu.Game.Tests/Visual/UserInterface/TestSceneFormControls.cs @@ -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!", diff --git a/osu.Game/Graphics/UserInterfaceV2/FormTextBox.cs b/osu.Game/Graphics/UserInterfaceV2/FormTextBox.cs index 7b97c8baf3..b393c56795 100644 --- a/osu.Game/Graphics/UserInterfaceV2/FormTextBox.cs +++ b/osu.Game/Graphics/UserInterfaceV2/FormTextBox.cs @@ -77,6 +77,11 @@ namespace osu.Game.Graphics.UserInterfaceV2 /// public LocalisableString PlaceholderText { get; init; } + /// + /// Maximum allowed length of text. + /// + 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) =>