Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix recent editor textbox regressions #31590

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ public TestSceneFormControls()
Current = { Disabled = true },
TabbableContentContainer = this,
},
new FormNumberBox
new FormNumberBox(allowDecimals: true)
{
Caption = "Number",
HintText = "Insert your favourite number",
Expand Down
20 changes: 9 additions & 11 deletions osu.Game/Graphics/UserInterfaceV2/FormNumberBox.cs
Original file line number Diff line number Diff line change
@@ -1,32 +1,30 @@
// Copyright (c) ppy Pty Ltd <[email protected]>. 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);

Check failure on line 26 in osu.Game/Graphics/UserInterfaceV2/FormNumberBox.cs

View workflow job for this annotation

GitHub Actions / Build only (iOS)

'TextInputType' does not contain a definition for 'Decimal'

Check failure on line 26 in osu.Game/Graphics/UserInterfaceV2/FormNumberBox.cs

View workflow job for this annotation

GitHub Actions / Build only (iOS)

'TextInputType' does not contain a definition for 'Decimal'

Check failure on line 26 in osu.Game/Graphics/UserInterfaceV2/FormNumberBox.cs

View workflow job for this annotation

GitHub Actions / Code Quality

'TextInputType' does not contain a definition for 'Decimal'

Check failure on line 26 in osu.Game/Graphics/UserInterfaceV2/FormNumberBox.cs

View workflow job for this annotation

GitHub Actions / Code Quality

'TextInputType' does not contain a definition for 'Decimal'

Check failure on line 26 in osu.Game/Graphics/UserInterfaceV2/FormNumberBox.cs

View workflow job for this annotation

GitHub Actions / Test (Windows, windows-latest, SingleThread)

'TextInputType' does not contain a definition for 'Decimal'

Check failure on line 26 in osu.Game/Graphics/UserInterfaceV2/FormNumberBox.cs

View workflow job for this annotation

GitHub Actions / Test (Windows, windows-latest, SingleThread)

'TextInputType' does not contain a definition for 'Decimal'

Check failure on line 26 in osu.Game/Graphics/UserInterfaceV2/FormNumberBox.cs

View workflow job for this annotation

GitHub Actions / Test (Windows, windows-latest, MultiThreaded)

'TextInputType' does not contain a definition for 'Decimal'

Check failure on line 26 in osu.Game/Graphics/UserInterfaceV2/FormNumberBox.cs

View workflow job for this annotation

GitHub Actions / Test (Windows, windows-latest, MultiThreaded)

'TextInputType' does not contain a definition for 'Decimal'

Check failure on line 26 in osu.Game/Graphics/UserInterfaceV2/FormNumberBox.cs

View workflow job for this annotation

GitHub Actions / Test (Linux, ubuntu-latest, SingleThread)

'TextInputType' does not contain a definition for 'Decimal'

Check failure on line 26 in osu.Game/Graphics/UserInterfaceV2/FormNumberBox.cs

View workflow job for this annotation

GitHub Actions / Test (Linux, ubuntu-latest, SingleThread)

'TextInputType' does not contain a definition for 'Decimal'

Check failure on line 26 in osu.Game/Graphics/UserInterfaceV2/FormNumberBox.cs

View workflow job for this annotation

GitHub Actions / Test (Linux, ubuntu-latest, MultiThreaded)

'TextInputType' does not contain a definition for 'Decimal'

Check failure on line 26 in osu.Game/Graphics/UserInterfaceV2/FormNumberBox.cs

View workflow job for this annotation

GitHub Actions / Test (Linux, ubuntu-latest, MultiThreaded)

'TextInputType' does not contain a definition for 'Decimal'
}

protected override bool CanAddCharacter(char character)
=> char.IsAsciiDigit(character) || (AllowDecimals && CultureInfo.CurrentCulture.NumberFormat.NumberDecimalSeparator.Contains(character));
}
}
}
3 changes: 1 addition & 2 deletions osu.Game/Graphics/UserInterfaceV2/FormSliderBar.cs
Original file line number Diff line number Diff line change
Expand Up @@ -119,15 +119,14 @@ private void load(OsuColour colours, OsuGame? game)
Caption = Caption,
TooltipText = HintText,
},
textBox = new FormNumberBox.InnerNumberBox
textBox = new FormNumberBox.InnerNumberBox(allowDecimals: true)
{
Anchor = Anchor.BottomLeft,
Origin = Anchor.BottomLeft,
RelativeSizeAxes = Axes.X,
Width = 0.5f,
CommitOnFocusLost = true,
SelectAllOnFocus = true,
AllowDecimals = true,
OnInputError = () =>
{
flashLayer.Colour = ColourInfo.GradientVertical(colours.Red3.Opacity(0), colours.Red3);
Expand Down
Loading