-
Notifications
You must be signed in to change notification settings - Fork 425
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
Add input type for decimal numbers #6498
base: master
Are you sure you want to change the base?
Conversation
/// <summary> | ||
/// The text input is numerical with decimal point. | ||
/// </summary> | ||
Decimal, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The only thing that worries me with having this separate is the potential of needing to switch between non-decimal and decimal input at some stage. But maybe that's not that frequent of a use case...
// todo: SDL does not have a corresponding type for "number with decimal point", fall back to text for now. | ||
// On iOS, using SDL_TEXTINPUT_TYPE_NUMBER does not offer a key for inserting a decimal. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This 100% needs to be reported to / requested from SDL though because iOS can 100% cope with this. <input type="number">
in browsers pulls up a symbols-only keyboard. This should be one-liner tier effort on their side.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Above issues is fixed, SDL_TEXTINPUT_TYPE_NUMBER
will now show "a keyboard with numbers and a decimal point" on iOS, the same as it does on Android.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@Susko3 Thanks for the upstream handling. It seems then we can make both Decimal
and Number
use the SDL_TEXTINPUT_TYPE_NUMBER
type.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@frenzibyte doesn't this make this PR dependent on an sdl bump then?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's sort of a soft dependency so wasn't sure if I should do that, but probably better safe than sorry.
if (InputProperties.Type.IsNumerical()) | ||
{ | ||
// if the input type is decimal and the character is a decimal separator, allow it. | ||
if (InputProperties.Type == TextInputType.Decimal && CultureInfo.CurrentCulture.NumberFormat.NumberDecimalSeparator.Contains(character)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should this support the minus sign of the current locale for negative numbers? On android, the number text input type has a -
key.
I think this also needs to allow NumberGroupSeparator
:
osu-framework/osu.Framework.Tests/Bindables/BindableDoubleTest.cs
Lines 106 to 109 in 91ab1ac
[TestCase("1.400,01", "de-DE", 1400.01)] | |
[TestCase("1 234,57", "ru-RU", 1234.57)] | |
[TestCase("1,094", "fr-FR", 1.094)] | |
[TestCase("1,400.01", "zh-CN", 1400.01)] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Makes sense, but if it's allowed here then it should be allowed in Number
, and so it starts to become out of scope. Better leave it as-is and/or change separately. Same applies to negative symbol.
Was using "TEXT" for iOS's sake, but that is now fixed in libsdl-org/SDL#12025.
Required to (fix) ppy/osu#31568.
Specifying a
Number
input type broke editor textboxes due to the type disallowing decimal characters from being entered. This disability is applied internally withinTextBox
and is not overridable withCanAddCharacter
(rightly so).As a proper fix for this, a specific input type for decimal numbers is added to support this. It has also came to my attention that displaying the software keyboard on iOS on a textbox that uses
TextInputType.Number
does not show a decimal button, which suggests that it is a good choice to add a different input type for decimal numbers. Unfortunately there's no corresponding SDL input type for decimal numbers, so this new input type is interpreted as "regular text" in SDL.In other words, using the new
Decimal
input type will show the full alphanumeric software keyboard just for the sake of allowing the user to insert decimal points.