diff --git a/src/Compatibility/Core/src/WinUI/EditorRenderer.cs b/src/Compatibility/Core/src/WinUI/EditorRenderer.cs
index cf280f897991..45f3b749df2b 100644
--- a/src/Compatibility/Core/src/WinUI/EditorRenderer.cs
+++ b/src/Compatibility/Core/src/WinUI/EditorRenderer.cs
@@ -249,6 +249,7 @@ void UpdateFont()
_fontApplied = true;
}
+ [PortHandler("Still pending to port IsSpellCheckEnabled")]
void UpdateInputScope()
{
Editor editor = Element;
diff --git a/src/Controls/samples/Controls.Sample/Pages/Controls/EditorPage.xaml b/src/Controls/samples/Controls.Sample/Pages/Controls/EditorPage.xaml
index 760c40a1e2f7..1cba067e2ef7 100644
--- a/src/Controls/samples/Controls.Sample/Pages/Controls/EditorPage.xaml
+++ b/src/Controls/samples/Controls.Sample/Pages/Controls/EditorPage.xaml
@@ -29,6 +29,11 @@
+
+
diff --git a/src/Core/src/Handlers/Editor/EditorHandler.Windows.cs b/src/Core/src/Handlers/Editor/EditorHandler.Windows.cs
index 970c99bf866a..4ff1006160dc 100644
--- a/src/Core/src/Handlers/Editor/EditorHandler.Windows.cs
+++ b/src/Core/src/Handlers/Editor/EditorHandler.Windows.cs
@@ -79,8 +79,10 @@ public static void MapIsReadOnly(EditorHandler handler, IEditor editor)
public static void MapTextColor(EditorHandler handler, IEditor editor) =>
handler.NativeView?.UpdateTextColor(editor);
- [MissingMapper]
- public static void MapKeyboard(EditorHandler handler, IEditor editor) { }
+ public static void MapKeyboard(EditorHandler handler, IEditor editor)
+ {
+ handler.NativeView?.UpdateKeyboard(editor);
+ }
void OnLostFocus(object? sender, RoutedEventArgs e)
{
diff --git a/src/Core/src/Platform/Windows/KeyboardExtensions.cs b/src/Core/src/Platform/Windows/KeyboardExtensions.cs
new file mode 100644
index 000000000000..f0a63ae15b83
--- /dev/null
+++ b/src/Core/src/Platform/Windows/KeyboardExtensions.cs
@@ -0,0 +1,86 @@
+using System;
+using System.Diagnostics;
+using Microsoft.UI.Xaml.Input;
+
+namespace Microsoft.Maui
+{
+ public static class KeyboardExtensions
+ {
+ public static InputScope ToInputScope(this Keyboard self)
+ {
+ if (self == null)
+ throw new ArgumentNullException("self");
+
+ var result = new InputScope();
+ var name = new InputScopeName();
+
+ if (self == Keyboard.Default)
+ {
+ name.NameValue = InputScopeNameValue.Default;
+ }
+ else if (self == Keyboard.Chat)
+ {
+ name.NameValue = InputScopeNameValue.Chat;
+ }
+ else if (self == Keyboard.Email)
+ {
+ name.NameValue = InputScopeNameValue.EmailSmtpAddress;
+ }
+ else if (self == Keyboard.Numeric)
+ {
+ name.NameValue = InputScopeNameValue.Number;
+ }
+ else if (self == Keyboard.Telephone)
+ {
+ name.NameValue = InputScopeNameValue.TelephoneNumber;
+ }
+ else if (self == Keyboard.Text)
+ {
+ name.NameValue = InputScopeNameValue.Default;
+ }
+ else if (self == Keyboard.Url)
+ {
+ name.NameValue = InputScopeNameValue.Url;
+ }
+ else
+ {
+ var custom = (CustomKeyboard)self;
+ var capitalizedSentenceEnabled = (custom.Flags & KeyboardFlags.CapitalizeSentence) == KeyboardFlags.CapitalizeSentence;
+ var capitalizedWordsEnabled = (custom.Flags & KeyboardFlags.CapitalizeWord) == KeyboardFlags.CapitalizeWord;
+ var capitalizedCharacterEnabled = (custom.Flags & KeyboardFlags.CapitalizeCharacter) == KeyboardFlags.CapitalizeCharacter;
+
+ var spellcheckEnabled = (custom.Flags & KeyboardFlags.Spellcheck) == KeyboardFlags.Spellcheck;
+ var suggestionsEnabled = (custom.Flags & KeyboardFlags.Suggestions) == KeyboardFlags.Suggestions;
+
+ InputScopeNameValue nameValue = InputScopeNameValue.Default;
+
+ if (capitalizedSentenceEnabled)
+ {
+ if (!spellcheckEnabled)
+ {
+ Debug.WriteLine(null, "CapitalizeSentence only works when spell check is enabled");
+ }
+ }
+ else if (capitalizedWordsEnabled)
+ {
+ if (!spellcheckEnabled)
+ {
+ Debug.WriteLine(null, "CapitalizeWord only works when spell check is enabled");
+ }
+
+ nameValue = InputScopeNameValue.NameOrPhoneNumber;
+ }
+
+ if (capitalizedCharacterEnabled)
+ {
+ Debug.WriteLine(null, "WinUI does not support CapitalizeCharacter");
+ }
+
+ name.NameValue = nameValue;
+ }
+
+ result.Names.Add(name);
+ return result;
+ }
+ }
+}
\ No newline at end of file
diff --git a/src/Core/src/Platform/Windows/TextBoxExtensions.cs b/src/Core/src/Platform/Windows/TextBoxExtensions.cs
index 465251000a94..4087a87058c4 100644
--- a/src/Core/src/Platform/Windows/TextBoxExtensions.cs
+++ b/src/Core/src/Platform/Windows/TextBoxExtensions.cs
@@ -125,6 +125,28 @@ public static void UpdateIsPassword(this MauiTextBox textBox, IEntry entry)
{
textBox.IsPassword = entry.IsPassword;
}
+
+ public static void UpdateKeyboard(this MauiTextBox textBox, IEditor editor)
+ {
+ textBox.UpdateInputScope(editor);
+ }
+
+ internal static void UpdateInputScope(this MauiTextBox textBox, ITextInput textInput)
+ {
+ if (textInput.Keyboard is CustomKeyboard custom)
+ {
+ textBox.IsTextPredictionEnabled = (custom.Flags & KeyboardFlags.Suggestions) != 0;
+ textBox.IsSpellCheckEnabled = (custom.Flags & KeyboardFlags.Spellcheck) != 0;
+ }
+ else
+ {
+ textBox.IsTextPredictionEnabled = textInput.IsTextPredictionEnabled;
+
+ // TODO: Update IsSpellCheckEnabled
+ }
+
+ textBox.InputScope = textInput.Keyboard.ToInputScope();
+ }
public static void UpdateHorizontalTextAlignment(this MauiTextBox textBox, IEntry entry)
{