From 7f11dc489f989980b1a52f53a7e33e8f058657f2 Mon Sep 17 00:00:00 2001 From: Salman Alshamrani Date: Wed, 1 Jan 2025 15:55:35 -0500 Subject: [PATCH] Disable autocapitalisation in text input by default --- .../Visual/UserInterface/TestSceneTextBox.cs | 10 +++++++++- osu.Framework/Input/TextInputProperties.cs | 3 ++- osu.Framework/Platform/SDL3/SDL3Window_Input.cs | 6 ++++++ 3 files changed, 17 insertions(+), 2 deletions(-) diff --git a/osu.Framework.Tests/Visual/UserInterface/TestSceneTextBox.cs b/osu.Framework.Tests/Visual/UserInterface/TestSceneTextBox.cs index e209afa3aa..f5921ea9e3 100644 --- a/osu.Framework.Tests/Visual/UserInterface/TestSceneTextBox.cs +++ b/osu.Framework.Tests/Visual/UserInterface/TestSceneTextBox.cs @@ -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 }); diff --git a/osu.Framework/Input/TextInputProperties.cs b/osu.Framework/Input/TextInputProperties.cs index e44bb6dbd2..1175e41417 100644 --- a/osu.Framework/Input/TextInputProperties.cs +++ b/osu.Framework/Input/TextInputProperties.cs @@ -16,5 +16,6 @@ namespace osu.Framework.Input /// while others will ignore and always have the IME (dis)allowed. /// /// - public record struct TextInputProperties(TextInputType Type, bool AllowIme = true); + /// Whether text should be automatically capitalised. + public record struct TextInputProperties(TextInputType Type, bool AllowIme = true, bool AutoCapitalisation = false); } diff --git a/osu.Framework/Platform/SDL3/SDL3Window_Input.cs b/osu.Framework/Platform/SDL3/SDL3Window_Input.cs index e501392d78..548f27c6b6 100644 --- a/osu.Framework/Platform/SDL3/SDL3Window_Input.cs +++ b/osu.Framework/Platform/SDL3/SDL3Window_Input.cs @@ -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); });