Skip to content

Commit 7f11dc4

Browse files
committed
Disable autocapitalisation in text input by default
1 parent 416718c commit 7f11dc4

File tree

3 files changed

+17
-2
lines changed

3 files changed

+17
-2
lines changed

osu.Framework.Tests/Visual/UserInterface/TestSceneTextBox.cs

+9-1
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,15 @@ public void VariousTextBoxes()
9595

9696
textBoxes.Add(new CustomTextBox
9797
{
98-
Text = @"Custom textbox",
98+
PlaceholderText = "Custom textbox",
99+
Size = new Vector2(500, 30),
100+
TabbableContentContainer = textBoxes
101+
});
102+
103+
textBoxes.Add(new BasicTextBox
104+
{
105+
InputProperties = new TextInputProperties(TextInputType.Text, AutoCapitalisation: true),
106+
Text = "Auto-capitalised textbox",
99107
Size = new Vector2(500, 30),
100108
TabbableContentContainer = textBoxes
101109
});

osu.Framework/Input/TextInputProperties.cs

+2-1
Original file line numberDiff line numberDiff line change
@@ -16,5 +16,6 @@ namespace osu.Framework.Input
1616
/// while others will ignore and always have the IME (dis)allowed.
1717
/// </para>
1818
/// </param>
19-
public record struct TextInputProperties(TextInputType Type, bool AllowIme = true);
19+
/// <param name="AutoCapitalisation">Whether text should be automatically capitalised.</param>
20+
public record struct TextInputProperties(TextInputType Type, bool AllowIme = true, bool AutoCapitalisation = false);
2021
}

osu.Framework/Platform/SDL3/SDL3Window_Input.cs

+6
Original file line numberDiff line numberDiff line change
@@ -195,6 +195,12 @@ public virtual void StartTextInput(TextInputProperties properties) => ScheduleCo
195195

196196
var props = currentTextInputProperties.Value;
197197
SDL_SetNumberProperty(props, SDL_PROP_TEXTINPUT_TYPE_NUMBER, (long)properties.Type.ToSDLTextInputType());
198+
199+
if (!properties.AutoCapitalisation)
200+
SDL_SetNumberProperty(props, SDL_PROP_TEXTINPUT_CAPITALIZATION_NUMBER, (long)SDL_Capitalization.SDL_CAPITALIZE_NONE);
201+
else
202+
SDL_ClearProperty(props, SDL_PROP_TEXTINPUT_CAPITALIZATION_NUMBER);
203+
198204
SDL_StartTextInputWithProperties(SDLWindowHandle, props);
199205
});
200206

0 commit comments

Comments
 (0)