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

Add text input type for alphanumeric code #6513

Merged
merged 1 commit into from
Jan 26, 2025
Merged
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
19 changes: 12 additions & 7 deletions osu.Framework/Input/TextInputType.cs
Original file line number Diff line number Diff line change
Expand Up @@ -16,22 +16,27 @@ public enum TextInputType
Name,

/// <summary>
/// The text input is an email address.
/// The text input is an alphanumeric code which can be visible to the user.
/// </summary>
EmailAddress,
Code,

/// <summary>
/// The text input is a username.
/// The text input is numerical.
/// </summary>
Username,
Number,

/// <summary>
/// The text input is numerical.
/// The text input is an email address.
/// </summary>
Number,
EmailAddress,

/// <summary>
/// The text input is a username. This may hint the operating system to provide a shortcut to a credentials manager for autofill.
/// </summary>
Username,

/// <summary>
/// The text input is a password hidden from the user.
/// The text input is a password hidden from the user. This may hint the operating system to provide a shortcut to a credentials manager for autofill.
/// </summary>
Password,

Expand Down
1 change: 1 addition & 0 deletions osu.Framework/Platform/SDL3/SDL3Extensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -1017,6 +1017,7 @@ public static SDL_TextInputType ToSDLTextInputType(this TextInputType type)
{
default:
case TextInputType.Text:
case TextInputType.Code:
return SDL_TextInputType.SDL_TEXTINPUT_TYPE_TEXT;

case TextInputType.Name:
Expand Down
5 changes: 5 additions & 0 deletions osu.Framework/Platform/SDL3/SDL3Window_Input.cs
Original file line number Diff line number Diff line change
Expand Up @@ -201,6 +201,11 @@ public virtual void StartTextInput(TextInputProperties properties) => ScheduleCo
else
SDL_ClearProperty(props, SDL_PROP_TEXTINPUT_CAPITALIZATION_NUMBER);

if (properties.Type == TextInputType.Code)
SDL_SetBooleanProperty(props, SDL_PROP_TEXTINPUT_AUTOCORRECT_BOOLEAN, false);
else
SDL_ClearProperty(props, SDL_PROP_TEXTINPUT_AUTOCORRECT_BOOLEAN);

SDL_StartTextInputWithProperties(SDLWindowHandle, props);
});

Expand Down
Loading