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

Disable auto-capitalisation in textboxes #6478

Merged
merged 2 commits into from
Jan 21, 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
10 changes: 9 additions & 1 deletion osu.Framework.Tests/Visual/UserInterface/TestSceneTextBox.cs
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,15 @@ public void VariousTextBoxes()

textBoxes.Add(new CustomTextBox
{
Text = @"Custom textbox",
PlaceholderText = "Custom textbox",
Size = new Vector2(500, 30),
TabbableContentContainer = textBoxes
});

textBoxes.Add(new BasicTextBox
{
InputProperties = new TextInputProperties(TextInputType.Text, AutoCapitalisation: true),
Text = "Auto-capitalised textbox",
Size = new Vector2(500, 30),
TabbableContentContainer = textBoxes
});
Expand Down
3 changes: 2 additions & 1 deletion osu.Framework/Input/TextInputProperties.cs
Original file line number Diff line number Diff line change
Expand Up @@ -16,5 +16,6 @@ namespace osu.Framework.Input
/// while others will ignore and always have the IME (dis)allowed.
/// </para>
/// </param>
public record struct TextInputProperties(TextInputType Type, bool AllowIme = true);
/// <param name="AutoCapitalisation">Whether text should be automatically capitalised.</param>
public record struct TextInputProperties(TextInputType Type, bool AllowIme = true, bool AutoCapitalisation = false);
}
6 changes: 6 additions & 0 deletions osu.Framework/Platform/SDL3/SDL3Window_Input.cs
Original file line number Diff line number Diff line change
Expand Up @@ -195,6 +195,12 @@ public virtual void StartTextInput(TextInputProperties properties) => ScheduleCo

var props = currentTextInputProperties.Value;
SDL_SetNumberProperty(props, SDL_PROP_TEXTINPUT_TYPE_NUMBER, (long)properties.Type.ToSDLTextInputType());

if (!properties.AutoCapitalisation)
SDL_SetNumberProperty(props, SDL_PROP_TEXTINPUT_CAPITALIZATION_NUMBER, (long)SDL_Capitalization.SDL_CAPITALIZE_NONE);
else
SDL_ClearProperty(props, SDL_PROP_TEXTINPUT_CAPITALIZATION_NUMBER);

SDL_StartTextInputWithProperties(SDLWindowHandle, props);
});

Expand Down
Loading