Fix numeric SWKB validation (#5627)
* Fix numeric swkbd validation * GTK
This commit is contained in:
parent
437c78e198
commit
12cbacffca
5 changed files with 26 additions and 9 deletions
|
@ -544,7 +544,7 @@
|
||||||
"SwkbdMinCharacters": "Must be at least {0} characters long",
|
"SwkbdMinCharacters": "Must be at least {0} characters long",
|
||||||
"SwkbdMinRangeCharacters": "Must be {0}-{1} characters long",
|
"SwkbdMinRangeCharacters": "Must be {0}-{1} characters long",
|
||||||
"SoftwareKeyboard": "Software Keyboard",
|
"SoftwareKeyboard": "Software Keyboard",
|
||||||
"SoftwareKeyboardModeNumbersOnly": "Must be numbers only",
|
"SoftwareKeyboardModeNumeric": "Must be 0-9 or '.' only",
|
||||||
"SoftwareKeyboardModeAlphabet": "Must be non CJK-characters only",
|
"SoftwareKeyboardModeAlphabet": "Must be non CJK-characters only",
|
||||||
"SoftwareKeyboardModeASCII": "Must be ASCII text only",
|
"SoftwareKeyboardModeASCII": "Must be ASCII text only",
|
||||||
"DialogControllerAppletMessagePlayerRange": "Application requests {0} player(s) with:\n\nTYPES: {1}\n\nPLAYERS: {2}\n\n{3}Please open Settings and reconfigure Input now or press Close.",
|
"DialogControllerAppletMessagePlayerRange": "Application requests {0} player(s) with:\n\nTYPES: {1}\n\nPLAYERS: {2}\n\n{3}Please open Settings and reconfigure Input now or press Close.",
|
||||||
|
|
|
@ -136,10 +136,10 @@ namespace Ryujinx.Ava.UI.Controls
|
||||||
string localeText;
|
string localeText;
|
||||||
switch (mode)
|
switch (mode)
|
||||||
{
|
{
|
||||||
case KeyboardMode.NumbersOnly:
|
case KeyboardMode.Numeric:
|
||||||
localeText = LocaleManager.Instance.UpdateAndGetDynamicValue(LocaleKeys.SoftwareKeyboardModeNumbersOnly);
|
localeText = LocaleManager.Instance.UpdateAndGetDynamicValue(LocaleKeys.SoftwareKeyboardModeNumeric);
|
||||||
validationInfoText = string.IsNullOrEmpty(validationInfoText) ? localeText : string.Join("\n", validationInfoText, localeText);
|
validationInfoText = string.IsNullOrEmpty(validationInfoText) ? localeText : string.Join("\n", validationInfoText, localeText);
|
||||||
_checkInput = text => text.All(char.IsDigit);
|
_checkInput = text => text.All(NumericCharacterValidation.IsNumeric);
|
||||||
break;
|
break;
|
||||||
case KeyboardMode.Alphabet:
|
case KeyboardMode.Alphabet:
|
||||||
localeText = LocaleManager.Instance.UpdateAndGetDynamicValue(LocaleKeys.SoftwareKeyboardModeAlphabet);
|
localeText = LocaleManager.Instance.UpdateAndGetDynamicValue(LocaleKeys.SoftwareKeyboardModeAlphabet);
|
||||||
|
|
|
@ -11,9 +11,9 @@
|
||||||
Default = 0,
|
Default = 0,
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Only numbers allowed.
|
/// Only 0-9 or '.' allowed.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
NumbersOnly = 1,
|
Numeric = 1,
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Only ASCII characters allowed.
|
/// Only ASCII characters allowed.
|
||||||
|
|
|
@ -0,0 +1,17 @@
|
||||||
|
using System.Text.RegularExpressions;
|
||||||
|
|
||||||
|
namespace Ryujinx.HLE.HOS.Applets.SoftwareKeyboard
|
||||||
|
{
|
||||||
|
public static partial class NumericCharacterValidation
|
||||||
|
{
|
||||||
|
public static bool IsNumeric(char value)
|
||||||
|
{
|
||||||
|
Regex regex = NumericRegex();
|
||||||
|
|
||||||
|
return regex.IsMatch(value.ToString());
|
||||||
|
}
|
||||||
|
|
||||||
|
[GeneratedRegex("[0-9]|.")]
|
||||||
|
private static partial Regex NumericRegex();
|
||||||
|
}
|
||||||
|
}
|
|
@ -90,9 +90,9 @@ namespace Ryujinx.Ui.Applet
|
||||||
|
|
||||||
switch (mode)
|
switch (mode)
|
||||||
{
|
{
|
||||||
case KeyboardMode.NumbersOnly:
|
case KeyboardMode.Numeric:
|
||||||
_validationInfoText += "<i>Must be numbers only.</i>";
|
_validationInfoText += "<i>Must be 0-9 or '.' only.</i>";
|
||||||
_checkInput = text => text.All(char.IsDigit);
|
_checkInput = text => text.All(NumericCharacterValidation.IsNumeric);
|
||||||
break;
|
break;
|
||||||
case KeyboardMode.Alphabet:
|
case KeyboardMode.Alphabet:
|
||||||
_validationInfoText += "<i>Must be non CJK-characters only.</i>";
|
_validationInfoText += "<i>Must be non CJK-characters only.</i>";
|
||||||
|
|
Loading…
Reference in a new issue