mirror of
https://github.com/ppy/osu.git
synced 2024-11-16 13:17:26 +08:00
45a6a743a2
Spotted in passing in https://discord.com/channels/188630481301012481/1097318920991559880/1291693852981329981.
27 lines
878 B
C#
27 lines
878 B
C#
// 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;
|
|
|
|
namespace osu.Game.Graphics.UserInterfaceV2
|
|
{
|
|
public partial class FormNumberBox : FormTextBox
|
|
{
|
|
public bool AllowDecimals { get; init; }
|
|
|
|
internal override InnerTextBox CreateTextBox() => new InnerNumberBox
|
|
{
|
|
AllowDecimals = AllowDecimals,
|
|
SelectAllOnFocus = true,
|
|
};
|
|
|
|
internal partial class InnerNumberBox : InnerTextBox
|
|
{
|
|
public bool AllowDecimals { get; init; }
|
|
|
|
protected override bool CanAddCharacter(char character)
|
|
=> char.IsAsciiDigit(character) || (AllowDecimals && CultureInfo.CurrentCulture.NumberFormat.NumberDecimalSeparator.Contains(character));
|
|
}
|
|
}
|
|
}
|