mirror of
https://github.com/ppy/osu.git
synced 2025-01-31 05:23:21 +08:00
Merge pull request #31590 from frenzibyte/fix-editor-textbox-regressions
Fix recent editor textbox regressions
This commit is contained in:
commit
9a9f42c3ff
@ -53,7 +53,7 @@ namespace osu.Game.Tests.Visual.UserInterface
|
|||||||
Current = { Disabled = true },
|
Current = { Disabled = true },
|
||||||
TabbableContentContainer = this,
|
TabbableContentContainer = this,
|
||||||
},
|
},
|
||||||
new FormNumberBox
|
new FormNumberBox(allowDecimals: true)
|
||||||
{
|
{
|
||||||
Caption = "Number",
|
Caption = "Number",
|
||||||
HintText = "Insert your favourite number",
|
HintText = "Insert your favourite number",
|
||||||
|
@ -1,32 +1,30 @@
|
|||||||
// Copyright (c) ppy Pty Ltd <contact@ppy.sh>. Licensed under the MIT Licence.
|
// 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.
|
// See the LICENCE file in the repository root for full licence text.
|
||||||
|
|
||||||
using System.Globalization;
|
|
||||||
using osu.Framework.Input;
|
using osu.Framework.Input;
|
||||||
|
|
||||||
namespace osu.Game.Graphics.UserInterfaceV2
|
namespace osu.Game.Graphics.UserInterfaceV2
|
||||||
{
|
{
|
||||||
public partial class FormNumberBox : FormTextBox
|
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,
|
SelectAllOnFocus = true,
|
||||||
};
|
};
|
||||||
|
|
||||||
internal partial class InnerNumberBox : InnerTextBox
|
internal partial class InnerNumberBox : InnerTextBox
|
||||||
{
|
{
|
||||||
public bool AllowDecimals { get; init; }
|
public InnerNumberBox(bool allowDecimals)
|
||||||
|
|
||||||
public InnerNumberBox()
|
|
||||||
{
|
{
|
||||||
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));
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -119,7 +119,7 @@ namespace osu.Game.Graphics.UserInterfaceV2
|
|||||||
Caption = Caption,
|
Caption = Caption,
|
||||||
TooltipText = HintText,
|
TooltipText = HintText,
|
||||||
},
|
},
|
||||||
textBox = new FormNumberBox.InnerNumberBox
|
textBox = new FormNumberBox.InnerNumberBox(allowDecimals: true)
|
||||||
{
|
{
|
||||||
Anchor = Anchor.BottomLeft,
|
Anchor = Anchor.BottomLeft,
|
||||||
Origin = Anchor.BottomLeft,
|
Origin = Anchor.BottomLeft,
|
||||||
@ -127,7 +127,6 @@ namespace osu.Game.Graphics.UserInterfaceV2
|
|||||||
Width = 0.5f,
|
Width = 0.5f,
|
||||||
CommitOnFocusLost = true,
|
CommitOnFocusLost = true,
|
||||||
SelectAllOnFocus = true,
|
SelectAllOnFocus = true,
|
||||||
AllowDecimals = true,
|
|
||||||
OnInputError = () =>
|
OnInputError = () =>
|
||||||
{
|
{
|
||||||
flashLayer.Colour = ColourInfo.GradientVertical(colours.Red3.Opacity(0), colours.Red3);
|
flashLayer.Colour = ColourInfo.GradientVertical(colours.Red3.Opacity(0), colours.Red3);
|
||||||
|
Loading…
Reference in New Issue
Block a user