1
0
mirror of https://github.com/ppy/osu.git synced 2025-01-30 20:32:55 +08:00

Merge pull request #31590 from frenzibyte/fix-editor-textbox-regressions

Fix recent editor textbox regressions
This commit is contained in:
Bartłomiej Dach 2025-01-29 12:08:42 +01:00 committed by GitHub
commit 9a9f42c3ff
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
3 changed files with 11 additions and 14 deletions

View File

@ -53,7 +53,7 @@ namespace osu.Game.Tests.Visual.UserInterface
Current = { Disabled = true },
TabbableContentContainer = this,
},
new FormNumberBox
new FormNumberBox(allowDecimals: true)
{
Caption = "Number",
HintText = "Insert your favourite number",

View File

@ -1,32 +1,30 @@
// Copyright (c) ppy Pty Ltd <contact@ppy.sh>. Licensed under the MIT Licence.
// See the LICENCE file in the repository root for full licence text.
using System.Globalization;
using osu.Framework.Input;
namespace osu.Game.Graphics.UserInterfaceV2
{
public partial class FormNumberBox : FormTextBox
{
public bool AllowDecimals { get; init; }
private readonly bool allowDecimals;
internal override InnerTextBox CreateTextBox() => new InnerNumberBox
public FormNumberBox(bool allowDecimals = false)
{
this.allowDecimals = allowDecimals;
}
internal override InnerTextBox CreateTextBox() => new InnerNumberBox(allowDecimals)
{
AllowDecimals = AllowDecimals,
SelectAllOnFocus = true,
};
internal partial class InnerNumberBox : InnerTextBox
{
public bool AllowDecimals { get; init; }
public InnerNumberBox()
public InnerNumberBox(bool allowDecimals)
{
InputProperties = new TextInputProperties(TextInputType.Number, false);
InputProperties = new TextInputProperties(allowDecimals ? TextInputType.Decimal : TextInputType.Number, false);
}
protected override bool CanAddCharacter(char character)
=> char.IsAsciiDigit(character) || (AllowDecimals && CultureInfo.CurrentCulture.NumberFormat.NumberDecimalSeparator.Contains(character));
}
}
}

View File

@ -119,7 +119,7 @@ namespace osu.Game.Graphics.UserInterfaceV2
Caption = Caption,
TooltipText = HintText,
},
textBox = new FormNumberBox.InnerNumberBox
textBox = new FormNumberBox.InnerNumberBox(allowDecimals: true)
{
Anchor = Anchor.BottomLeft,
Origin = Anchor.BottomLeft,
@ -127,7 +127,6 @@ namespace osu.Game.Graphics.UserInterfaceV2
Width = 0.5f,
CommitOnFocusLost = true,
SelectAllOnFocus = true,
AllowDecimals = true,
OnInputError = () =>
{
flashLayer.Colour = ColourInfo.GradientVertical(colours.Red3.Opacity(0), colours.Red3);