diff --git a/src/SamplesApp/SamplesApp.UITests/Windows_UI_Xaml_Controls/TextBoxTests/TextBoxTests.cs b/src/SamplesApp/SamplesApp.UITests/Windows_UI_Xaml_Controls/TextBoxTests/TextBoxTests.cs index 62e6eba22f75..b1bda2034eb4 100644 --- a/src/SamplesApp/SamplesApp.UITests/Windows_UI_Xaml_Controls/TextBoxTests/TextBoxTests.cs +++ b/src/SamplesApp/SamplesApp.UITests/Windows_UI_Xaml_Controls/TextBoxTests/TextBoxTests.cs @@ -557,5 +557,78 @@ public void TextBox_IsReadOnly_AcceptsReturn_Test() multilineTextRect.Height.Should().Be(multilineReadonlyTextRect.Height, because: "toggling IsReadOnly should not affect AcceptsReturn=True(multiline) TextBox.Height"); normalTextRect.Height.Should().NotBe(multilineTextRect.Height, because: "toggling AcceptsReturn should not affect TextBox.Height"); } + + [Test] + [AutoRetry] + [ActivePlatforms(Platform.Android)] + public void TextBox_CharacterCasingNormal_ShouldAcceptAllCasing_Test() + { + const string text = "Uno Platform"; + + Run("UITests.Shared.Windows_UI_Xaml_Controls.TextBoxTests.TextBox_CharacterCasing"); + + var normalCasingTextBox = _app.Marked("NormalCasingTextBox"); + + normalCasingTextBox.Tap(); + normalCasingTextBox.ClearText(); + normalCasingTextBox.EnterText(text); + + Assert.AreEqual(text, normalCasingTextBox.GetDependencyPropertyValue("Text")?.ToString()); + } + + [Test] + [AutoRetry] + [ActivePlatforms(Platform.Android)] + public void TextBox_CharacterCasingDefault_ShouldAcceptAllCasing_Test() + { + const string text = "Uno Platform"; + + Run("UITests.Shared.Windows_UI_Xaml_Controls.TextBoxTests.TextBox_CharacterCasing"); + + var defaultCasingTextBox = _app.Marked("DefaultCasingTextBox"); + + defaultCasingTextBox.Tap(); + defaultCasingTextBox.ClearText(); + defaultCasingTextBox.EnterText(text); + + Assert.AreEqual(text, defaultCasingTextBox.GetDependencyPropertyValue("Text")?.ToString()); + } + + [Test] + [AutoRetry] + [ActivePlatforms(Platform.Android)] + public void TextBox_CharacterCasingLower_ShouldBeAllLower_Test() + { + const string text = "Uno Platform"; + + Run("UITests.Shared.Windows_UI_Xaml_Controls.TextBoxTests.TextBox_CharacterCasing"); + + var lowerCasingTextBox = _app.Marked("LowerCasingTextBox"); + + lowerCasingTextBox.Tap(); + lowerCasingTextBox.ClearText(); + lowerCasingTextBox.EnterText(text); + + Assert.AreEqual(text.ToLowerInvariant(), lowerCasingTextBox.GetDependencyPropertyValue("Text")?.ToString()); + } + + [Test] + [AutoRetry] + [ActivePlatforms(Platform.Android)] + public void TextBox_CharacterCasingUpper_ShouldBeAllUpper_Test() + { + const string text = "Uno Platform"; + + Run("UITests.Shared.Windows_UI_Xaml_Controls.TextBoxTests.TextBox_CharacterCasing"); + + var upperCasingTextBox = _app.Marked("UpperCasingTextBox"); + + upperCasingTextBox.Tap(); + upperCasingTextBox.ClearText(); + upperCasingTextBox.EnterText(text); + + Assert.AreEqual(text.ToUpperInvariant(), upperCasingTextBox.GetDependencyPropertyValue("Text")?.ToString()); + } + } } diff --git a/src/SamplesApp/UITests.Shared/UITests.Shared.projitems b/src/SamplesApp/UITests.Shared/UITests.Shared.projitems index 6410655e8544..428c91e40ee7 100644 --- a/src/SamplesApp/UITests.Shared/UITests.Shared.projitems +++ b/src/SamplesApp/UITests.Shared/UITests.Shared.projitems @@ -1129,6 +1129,10 @@ Designer MSBuild:Compile + + Designer + MSBuild:Compile + Designer MSBuild:Compile @@ -4192,6 +4196,9 @@ TextBox_Binding_Null.xaml + + TextBox_CharacterCasing.xaml + TextBox_CornerRadius.xaml diff --git a/src/SamplesApp/UITests.Shared/Windows_UI_Xaml_Controls/TextBox/TextBox_CharacterCasing.xaml b/src/SamplesApp/UITests.Shared/Windows_UI_Xaml_Controls/TextBox/TextBox_CharacterCasing.xaml new file mode 100644 index 000000000000..7456ca18e146 --- /dev/null +++ b/src/SamplesApp/UITests.Shared/Windows_UI_Xaml_Controls/TextBox/TextBox_CharacterCasing.xaml @@ -0,0 +1,33 @@ + + + + + + + + + + + + + diff --git a/src/SamplesApp/UITests.Shared/Windows_UI_Xaml_Controls/TextBox/TextBox_CharacterCasing.xaml.cs b/src/SamplesApp/UITests.Shared/Windows_UI_Xaml_Controls/TextBox/TextBox_CharacterCasing.xaml.cs new file mode 100644 index 000000000000..d1308c0720b8 --- /dev/null +++ b/src/SamplesApp/UITests.Shared/Windows_UI_Xaml_Controls/TextBox/TextBox_CharacterCasing.xaml.cs @@ -0,0 +1,33 @@ +using System; +using System.Collections.Generic; +using System.IO; +using System.Linq; +using System.Runtime.InteropServices.WindowsRuntime; +using Uno.UI.Samples.Controls; +using Windows.Foundation; +using Windows.Foundation.Collections; +using Windows.UI.Xaml; +using Windows.UI.Xaml.Controls; +using Windows.UI.Xaml.Controls.Primitives; +using Windows.UI.Xaml.Data; +using Windows.UI.Xaml.Input; +using Windows.UI.Xaml.Media; +using Windows.UI.Xaml.Navigation; + +// The Blank Page item template is documented at https://go.microsoft.com/fwlink/?LinkId=234238 + +namespace UITests.Shared.Windows_UI_Xaml_Controls.TextBoxTests +{ + /// + /// An empty page that can be used on its own or navigated to within a Frame. + /// + /// + [SampleControlInfo("TextBox", description: "TextBox_CharacterCasing")] + public sealed partial class TextBox_CharacterCasing : UserControl + { + public TextBox_CharacterCasing() + { + this.InitializeComponent(); + } + } +} diff --git a/src/Uno.UI/Generated/3.0.0.0/Windows.UI.Xaml.Controls/CharacterCasing.cs b/src/Uno.UI/Generated/3.0.0.0/Windows.UI.Xaml.Controls/CharacterCasing.cs index 9c5eb7abf0fb..09b04d1d8fc8 100644 --- a/src/Uno.UI/Generated/3.0.0.0/Windows.UI.Xaml.Controls/CharacterCasing.cs +++ b/src/Uno.UI/Generated/3.0.0.0/Windows.UI.Xaml.Controls/CharacterCasing.cs @@ -2,19 +2,19 @@ #pragma warning disable 114 // new keyword hiding namespace Windows.UI.Xaml.Controls { - #if __ANDROID__ || __IOS__ || NET461 || __WASM__ || __SKIA__ || __NETSTD_REFERENCE__ || __MACOS__ - #if __ANDROID__ || __IOS__ || NET461 || __WASM__ || __SKIA__ || __NETSTD_REFERENCE__ || __MACOS__ + #if false || false || false || false || false || false || false + #if false || false || false || false || false || false || false [global::Uno.NotImplemented] #endif - public enum CharacterCasing + public enum CharacterCasing { - #if __ANDROID__ || __IOS__ || NET461 || __WASM__ || __SKIA__ || __NETSTD_REFERENCE__ || __MACOS__ + #if false || false || false || false || false || false || false Normal, #endif - #if __ANDROID__ || __IOS__ || NET461 || __WASM__ || __SKIA__ || __NETSTD_REFERENCE__ || __MACOS__ + #if false || false || false || false || false || false || false Lower, #endif - #if __ANDROID__ || __IOS__ || NET461 || __WASM__ || __SKIA__ || __NETSTD_REFERENCE__ || __MACOS__ + #if false || false || false || false || false || false || false Upper, #endif } diff --git a/src/Uno.UI/Generated/3.0.0.0/Windows.UI.Xaml.Controls/TextBox.cs b/src/Uno.UI/Generated/3.0.0.0/Windows.UI.Xaml.Controls/TextBox.cs index 446936151c94..947d5b090394 100644 --- a/src/Uno.UI/Generated/3.0.0.0/Windows.UI.Xaml.Controls/TextBox.cs +++ b/src/Uno.UI/Generated/3.0.0.0/Windows.UI.Xaml.Controls/TextBox.cs @@ -5,7 +5,7 @@ namespace Windows.UI.Xaml.Controls #if false || false || false || false || false || false || false [global::Uno.NotImplemented] #endif - public partial class TextBox + public partial class TextBox { // Skipping already declared property TextWrapping // Skipping already declared property TextAlignment @@ -172,8 +172,8 @@ public bool PreventKeyboardDisplayOnProgrammaticFocus this.SetValue(HorizontalTextAlignmentProperty, value); } } - #endif - #if __ANDROID__ || __IOS__ || NET461 || __WASM__ || __SKIA__ || __NETSTD_REFERENCE__ || __MACOS__ +#endif +#if false || false || false || false || false || false || false [global::Uno.NotImplemented("__ANDROID__", "__IOS__", "NET461", "__WASM__", "__SKIA__", "__NETSTD_REFERENCE__", "__MACOS__")] public global::Windows.UI.Xaml.Controls.CharacterCasing CharacterCasing { @@ -186,8 +186,8 @@ public bool PreventKeyboardDisplayOnProgrammaticFocus this.SetValue(CharacterCasingProperty, value); } } - #endif - #if __ANDROID__ || __IOS__ || NET461 || __WASM__ || __SKIA__ || __NETSTD_REFERENCE__ || __MACOS__ +#endif +#if __ANDROID__ || __IOS__ || NET461 || __WASM__ || __SKIA__ || __NETSTD_REFERENCE__ || __MACOS__ [global::Uno.NotImplemented("__ANDROID__", "__IOS__", "NET461", "__WASM__", "__SKIA__", "__NETSTD_REFERENCE__", "__MACOS__")] public bool IsHandwritingViewEnabled { @@ -296,139 +296,139 @@ public bool CanUndo // Skipping already declared property HeaderProperty #if __ANDROID__ || __IOS__ || NET461 || __WASM__ || __SKIA__ || __NETSTD_REFERENCE__ || __MACOS__ [global::Uno.NotImplemented("__ANDROID__", "__IOS__", "NET461", "__WASM__", "__SKIA__", "__NETSTD_REFERENCE__", "__MACOS__")] - public static global::Windows.UI.Xaml.DependencyProperty SelectionHighlightColorProperty { get; } = + public static global::Windows.UI.Xaml.DependencyProperty SelectionHighlightColorProperty { get; } = Windows.UI.Xaml.DependencyProperty.Register( - nameof(SelectionHighlightColor), typeof(global::Windows.UI.Xaml.Media.SolidColorBrush), - typeof(global::Windows.UI.Xaml.Controls.TextBox), + nameof(SelectionHighlightColor), typeof(global::Windows.UI.Xaml.Media.SolidColorBrush), + typeof(global::Windows.UI.Xaml.Controls.TextBox), new FrameworkPropertyMetadata(default(global::Windows.UI.Xaml.Media.SolidColorBrush))); #endif #if false || __IOS__ || NET461 || __WASM__ || __SKIA__ || __NETSTD_REFERENCE__ || __MACOS__ [global::Uno.NotImplemented("__IOS__", "NET461", "__WASM__", "__SKIA__", "__NETSTD_REFERENCE__", "__MACOS__")] - public static global::Windows.UI.Xaml.DependencyProperty PreventKeyboardDisplayOnProgrammaticFocusProperty { get; } = + public static global::Windows.UI.Xaml.DependencyProperty PreventKeyboardDisplayOnProgrammaticFocusProperty { get; } = Windows.UI.Xaml.DependencyProperty.Register( - nameof(PreventKeyboardDisplayOnProgrammaticFocus), typeof(bool), - typeof(global::Windows.UI.Xaml.Controls.TextBox), + nameof(PreventKeyboardDisplayOnProgrammaticFocus), typeof(bool), + typeof(global::Windows.UI.Xaml.Controls.TextBox), new FrameworkPropertyMetadata(default(bool))); #endif // Skipping already declared property PlaceholderTextProperty #if __ANDROID__ || __IOS__ || NET461 || __WASM__ || __SKIA__ || __NETSTD_REFERENCE__ || __MACOS__ [global::Uno.NotImplemented("__ANDROID__", "__IOS__", "NET461", "__WASM__", "__SKIA__", "__NETSTD_REFERENCE__", "__MACOS__")] - public static global::Windows.UI.Xaml.DependencyProperty IsColorFontEnabledProperty { get; } = + public static global::Windows.UI.Xaml.DependencyProperty IsColorFontEnabledProperty { get; } = Windows.UI.Xaml.DependencyProperty.Register( - nameof(IsColorFontEnabled), typeof(bool), - typeof(global::Windows.UI.Xaml.Controls.TextBox), + nameof(IsColorFontEnabled), typeof(bool), + typeof(global::Windows.UI.Xaml.Controls.TextBox), new FrameworkPropertyMetadata(default(bool))); #endif #if __ANDROID__ || __IOS__ || NET461 || __WASM__ || __SKIA__ || __NETSTD_REFERENCE__ || __MACOS__ [global::Uno.NotImplemented("__ANDROID__", "__IOS__", "NET461", "__WASM__", "__SKIA__", "__NETSTD_REFERENCE__", "__MACOS__")] - public static global::Windows.UI.Xaml.DependencyProperty DesiredCandidateWindowAlignmentProperty { get; } = + public static global::Windows.UI.Xaml.DependencyProperty DesiredCandidateWindowAlignmentProperty { get; } = Windows.UI.Xaml.DependencyProperty.Register( - nameof(DesiredCandidateWindowAlignment), typeof(global::Windows.UI.Xaml.Controls.CandidateWindowAlignment), - typeof(global::Windows.UI.Xaml.Controls.TextBox), + nameof(DesiredCandidateWindowAlignment), typeof(global::Windows.UI.Xaml.Controls.CandidateWindowAlignment), + typeof(global::Windows.UI.Xaml.Controls.TextBox), new FrameworkPropertyMetadata(default(global::Windows.UI.Xaml.Controls.CandidateWindowAlignment))); #endif #if __ANDROID__ || __IOS__ || NET461 || __WASM__ || __SKIA__ || __NETSTD_REFERENCE__ || __MACOS__ [global::Uno.NotImplemented("__ANDROID__", "__IOS__", "NET461", "__WASM__", "__SKIA__", "__NETSTD_REFERENCE__", "__MACOS__")] - public static global::Windows.UI.Xaml.DependencyProperty TextReadingOrderProperty { get; } = + public static global::Windows.UI.Xaml.DependencyProperty TextReadingOrderProperty { get; } = Windows.UI.Xaml.DependencyProperty.Register( - nameof(TextReadingOrder), typeof(global::Windows.UI.Xaml.TextReadingOrder), - typeof(global::Windows.UI.Xaml.Controls.TextBox), + nameof(TextReadingOrder), typeof(global::Windows.UI.Xaml.TextReadingOrder), + typeof(global::Windows.UI.Xaml.Controls.TextBox), new FrameworkPropertyMetadata(default(global::Windows.UI.Xaml.TextReadingOrder))); #endif #if __ANDROID__ || __IOS__ || NET461 || __WASM__ || __SKIA__ || __NETSTD_REFERENCE__ || __MACOS__ [global::Uno.NotImplemented("__ANDROID__", "__IOS__", "NET461", "__WASM__", "__SKIA__", "__NETSTD_REFERENCE__", "__MACOS__")] - public static global::Windows.UI.Xaml.DependencyProperty SelectionHighlightColorWhenNotFocusedProperty { get; } = + public static global::Windows.UI.Xaml.DependencyProperty SelectionHighlightColorWhenNotFocusedProperty { get; } = Windows.UI.Xaml.DependencyProperty.Register( - nameof(SelectionHighlightColorWhenNotFocused), typeof(global::Windows.UI.Xaml.Media.SolidColorBrush), - typeof(global::Windows.UI.Xaml.Controls.TextBox), + nameof(SelectionHighlightColorWhenNotFocused), typeof(global::Windows.UI.Xaml.Media.SolidColorBrush), + typeof(global::Windows.UI.Xaml.Controls.TextBox), new FrameworkPropertyMetadata(default(global::Windows.UI.Xaml.Media.SolidColorBrush))); #endif #if __ANDROID__ || __IOS__ || NET461 || __WASM__ || __SKIA__ || __NETSTD_REFERENCE__ || __MACOS__ [global::Uno.NotImplemented("__ANDROID__", "__IOS__", "NET461", "__WASM__", "__SKIA__", "__NETSTD_REFERENCE__", "__MACOS__")] - public static global::Windows.UI.Xaml.DependencyProperty PlaceholderForegroundProperty { get; } = + public static global::Windows.UI.Xaml.DependencyProperty PlaceholderForegroundProperty { get; } = Windows.UI.Xaml.DependencyProperty.Register( - nameof(PlaceholderForeground), typeof(global::Windows.UI.Xaml.Media.Brush), - typeof(global::Windows.UI.Xaml.Controls.TextBox), + nameof(PlaceholderForeground), typeof(global::Windows.UI.Xaml.Media.Brush), + typeof(global::Windows.UI.Xaml.Controls.TextBox), new FrameworkPropertyMetadata(default(global::Windows.UI.Xaml.Media.Brush))); #endif #if __ANDROID__ || __IOS__ || NET461 || __WASM__ || __SKIA__ || __NETSTD_REFERENCE__ || __MACOS__ [global::Uno.NotImplemented("__ANDROID__", "__IOS__", "NET461", "__WASM__", "__SKIA__", "__NETSTD_REFERENCE__", "__MACOS__")] - public static global::Windows.UI.Xaml.DependencyProperty HorizontalTextAlignmentProperty { get; } = + public static global::Windows.UI.Xaml.DependencyProperty HorizontalTextAlignmentProperty { get; } = Windows.UI.Xaml.DependencyProperty.Register( - nameof(HorizontalTextAlignment), typeof(global::Windows.UI.Xaml.TextAlignment), - typeof(global::Windows.UI.Xaml.Controls.TextBox), + nameof(HorizontalTextAlignment), typeof(global::Windows.UI.Xaml.TextAlignment), + typeof(global::Windows.UI.Xaml.Controls.TextBox), new FrameworkPropertyMetadata(default(global::Windows.UI.Xaml.TextAlignment))); - #endif - #if __ANDROID__ || __IOS__ || NET461 || __WASM__ || __SKIA__ || __NETSTD_REFERENCE__ || __MACOS__ +#endif +#if false || false || false || false || false || false || false [global::Uno.NotImplemented("__ANDROID__", "__IOS__", "NET461", "__WASM__", "__SKIA__", "__NETSTD_REFERENCE__", "__MACOS__")] - public static global::Windows.UI.Xaml.DependencyProperty CharacterCasingProperty { get; } = + public static global::Windows.UI.Xaml.DependencyProperty CharacterCasingProperty { get; } = Windows.UI.Xaml.DependencyProperty.Register( - nameof(CharacterCasing), typeof(global::Windows.UI.Xaml.Controls.CharacterCasing), - typeof(global::Windows.UI.Xaml.Controls.TextBox), + nameof(CharacterCasing), typeof(global::Windows.UI.Xaml.Controls.CharacterCasing), + typeof(global::Windows.UI.Xaml.Controls.TextBox), new FrameworkPropertyMetadata(default(global::Windows.UI.Xaml.Controls.CharacterCasing))); - #endif - #if __ANDROID__ || __IOS__ || NET461 || __WASM__ || __SKIA__ || __NETSTD_REFERENCE__ || __MACOS__ +#endif +#if __ANDROID__ || __IOS__ || NET461 || __WASM__ || __SKIA__ || __NETSTD_REFERENCE__ || __MACOS__ [global::Uno.NotImplemented("__ANDROID__", "__IOS__", "NET461", "__WASM__", "__SKIA__", "__NETSTD_REFERENCE__", "__MACOS__")] - public static global::Windows.UI.Xaml.DependencyProperty IsHandwritingViewEnabledProperty { get; } = + public static global::Windows.UI.Xaml.DependencyProperty IsHandwritingViewEnabledProperty { get; } = Windows.UI.Xaml.DependencyProperty.Register( - nameof(IsHandwritingViewEnabled), typeof(bool), - typeof(global::Windows.UI.Xaml.Controls.TextBox), + nameof(IsHandwritingViewEnabled), typeof(bool), + typeof(global::Windows.UI.Xaml.Controls.TextBox), new FrameworkPropertyMetadata(default(bool))); #endif #if __ANDROID__ || __IOS__ || NET461 || __WASM__ || __SKIA__ || __NETSTD_REFERENCE__ || __MACOS__ [global::Uno.NotImplemented("__ANDROID__", "__IOS__", "NET461", "__WASM__", "__SKIA__", "__NETSTD_REFERENCE__", "__MACOS__")] - public static global::Windows.UI.Xaml.DependencyProperty HandwritingViewProperty { get; } = + public static global::Windows.UI.Xaml.DependencyProperty HandwritingViewProperty { get; } = Windows.UI.Xaml.DependencyProperty.Register( - nameof(HandwritingView), typeof(global::Windows.UI.Xaml.Controls.HandwritingView), - typeof(global::Windows.UI.Xaml.Controls.TextBox), + nameof(HandwritingView), typeof(global::Windows.UI.Xaml.Controls.HandwritingView), + typeof(global::Windows.UI.Xaml.Controls.TextBox), new FrameworkPropertyMetadata(default(global::Windows.UI.Xaml.Controls.HandwritingView))); #endif #if __ANDROID__ || __IOS__ || NET461 || __WASM__ || __SKIA__ || __NETSTD_REFERENCE__ || __MACOS__ [global::Uno.NotImplemented("__ANDROID__", "__IOS__", "NET461", "__WASM__", "__SKIA__", "__NETSTD_REFERENCE__", "__MACOS__")] - public static global::Windows.UI.Xaml.DependencyProperty SelectionFlyoutProperty { get; } = + public static global::Windows.UI.Xaml.DependencyProperty SelectionFlyoutProperty { get; } = Windows.UI.Xaml.DependencyProperty.Register( - nameof(SelectionFlyout), typeof(global::Windows.UI.Xaml.Controls.Primitives.FlyoutBase), - typeof(global::Windows.UI.Xaml.Controls.TextBox), + nameof(SelectionFlyout), typeof(global::Windows.UI.Xaml.Controls.Primitives.FlyoutBase), + typeof(global::Windows.UI.Xaml.Controls.TextBox), new FrameworkPropertyMetadata(default(global::Windows.UI.Xaml.Controls.Primitives.FlyoutBase))); #endif #if __ANDROID__ || __IOS__ || NET461 || __WASM__ || __SKIA__ || __NETSTD_REFERENCE__ || __MACOS__ [global::Uno.NotImplemented("__ANDROID__", "__IOS__", "NET461", "__WASM__", "__SKIA__", "__NETSTD_REFERENCE__", "__MACOS__")] - public static global::Windows.UI.Xaml.DependencyProperty ProofingMenuFlyoutProperty { get; } = + public static global::Windows.UI.Xaml.DependencyProperty ProofingMenuFlyoutProperty { get; } = Windows.UI.Xaml.DependencyProperty.Register( - nameof(ProofingMenuFlyout), typeof(global::Windows.UI.Xaml.Controls.Primitives.FlyoutBase), - typeof(global::Windows.UI.Xaml.Controls.TextBox), + nameof(ProofingMenuFlyout), typeof(global::Windows.UI.Xaml.Controls.Primitives.FlyoutBase), + typeof(global::Windows.UI.Xaml.Controls.TextBox), new FrameworkPropertyMetadata(default(global::Windows.UI.Xaml.Controls.Primitives.FlyoutBase))); #endif #if __ANDROID__ || __IOS__ || NET461 || __WASM__ || __SKIA__ || __NETSTD_REFERENCE__ || __MACOS__ [global::Uno.NotImplemented("__ANDROID__", "__IOS__", "NET461", "__WASM__", "__SKIA__", "__NETSTD_REFERENCE__", "__MACOS__")] - public static global::Windows.UI.Xaml.DependencyProperty DescriptionProperty { get; } = + public static global::Windows.UI.Xaml.DependencyProperty DescriptionProperty { get; } = Windows.UI.Xaml.DependencyProperty.Register( - nameof(Description), typeof(object), - typeof(global::Windows.UI.Xaml.Controls.TextBox), + nameof(Description), typeof(object), + typeof(global::Windows.UI.Xaml.Controls.TextBox), new FrameworkPropertyMetadata(default(object))); #endif #if __ANDROID__ || __IOS__ || NET461 || __WASM__ || __SKIA__ || __NETSTD_REFERENCE__ || __MACOS__ [global::Uno.NotImplemented("__ANDROID__", "__IOS__", "NET461", "__WASM__", "__SKIA__", "__NETSTD_REFERENCE__", "__MACOS__")] - public static global::Windows.UI.Xaml.DependencyProperty CanUndoProperty { get; } = + public static global::Windows.UI.Xaml.DependencyProperty CanUndoProperty { get; } = Windows.UI.Xaml.DependencyProperty.Register( - nameof(CanUndo), typeof(bool), - typeof(global::Windows.UI.Xaml.Controls.TextBox), + nameof(CanUndo), typeof(bool), + typeof(global::Windows.UI.Xaml.Controls.TextBox), new FrameworkPropertyMetadata(default(bool))); #endif #if __ANDROID__ || __IOS__ || NET461 || __WASM__ || __SKIA__ || __NETSTD_REFERENCE__ || __MACOS__ [global::Uno.NotImplemented("__ANDROID__", "__IOS__", "NET461", "__WASM__", "__SKIA__", "__NETSTD_REFERENCE__", "__MACOS__")] - public static global::Windows.UI.Xaml.DependencyProperty CanRedoProperty { get; } = + public static global::Windows.UI.Xaml.DependencyProperty CanRedoProperty { get; } = Windows.UI.Xaml.DependencyProperty.Register( - nameof(CanRedo), typeof(bool), - typeof(global::Windows.UI.Xaml.Controls.TextBox), + nameof(CanRedo), typeof(bool), + typeof(global::Windows.UI.Xaml.Controls.TextBox), new FrameworkPropertyMetadata(default(bool))); #endif #if __ANDROID__ || __IOS__ || NET461 || __WASM__ || __SKIA__ || __NETSTD_REFERENCE__ || __MACOS__ [global::Uno.NotImplemented("__ANDROID__", "__IOS__", "NET461", "__WASM__", "__SKIA__", "__NETSTD_REFERENCE__", "__MACOS__")] - public static global::Windows.UI.Xaml.DependencyProperty CanPasteClipboardContentProperty { get; } = + public static global::Windows.UI.Xaml.DependencyProperty CanPasteClipboardContentProperty { get; } = Windows.UI.Xaml.DependencyProperty.Register( - nameof(CanPasteClipboardContent), typeof(bool), - typeof(global::Windows.UI.Xaml.Controls.TextBox), + nameof(CanPasteClipboardContent), typeof(bool), + typeof(global::Windows.UI.Xaml.Controls.TextBox), new FrameworkPropertyMetadata(default(bool))); #endif // Skipping already declared method Windows.UI.Xaml.Controls.TextBox.TextBox() diff --git a/src/Uno.UI/UI/Xaml/Controls/CharacterCasing.cs b/src/Uno.UI/UI/Xaml/Controls/CharacterCasing.cs new file mode 100644 index 000000000000..9824e613ad3f --- /dev/null +++ b/src/Uno.UI/UI/Xaml/Controls/CharacterCasing.cs @@ -0,0 +1,11 @@ +using System; + +namespace Windows.UI.Xaml.Controls +{ + public enum CharacterCasing + { + Normal, + Lower, + Upper + } +} diff --git a/src/Uno.UI/UI/Xaml/Controls/TextBox/TextBox.Android.cs b/src/Uno.UI/UI/Xaml/Controls/TextBox/TextBox.Android.cs index b992f4bf9c39..72f967ee5392 100644 --- a/src/Uno.UI/UI/Xaml/Controls/TextBox/TextBox.Android.cs +++ b/src/Uno.UI/UI/Xaml/Controls/TextBox/TextBox.Android.cs @@ -1,4 +1,6 @@ using System; +using System.Collections.Generic; +using System.Globalization; using System.Linq; using System.Threading.Tasks; using Android.App; @@ -22,6 +24,7 @@ using Windows.UI.Xaml.Input; using Windows.UI.Xaml.Media; using static Android.Widget.TextView; +using Math = System.Math; namespace Windows.UI.Xaml.Controls { @@ -529,5 +532,76 @@ public bool OnEditorAction(TextView v, [GeneratedEnum] ImeAction actionId, KeyEv // Otherwise we return true to allow the focus to change correctly. return actionId != ImeAction.ImeNull; } + + partial void OnTextCharacterCasingChangedPartial(DependencyPropertyChangedEventArgs e) + { + if (_textBoxView == null) + { + return; + } + + var casing = (CharacterCasing)e.NewValue; + + UpdateCasing(casing); + } + + private void UpdateCasing(CharacterCasing characterCasing) + { + var currentFilters = _textBoxView.GetFilters()?.ToList() ?? new List(); + + //Remove any casing filters before applying new ones. + currentFilters.Remove(a => a is InputFilterAllLower || a is InputFilterAllCaps); + + switch (characterCasing) + { + case CharacterCasing.Lower: + var lowerFilter = new List(currentFilters) + { + new InputFilterAllLower() + }; + _textBoxView.SetFilters(lowerFilter.ToArray()); + + break; + case CharacterCasing.Upper: + var upperFilter = new List(currentFilters) + { + new InputFilterAllCaps() + }; + _textBoxView.SetFilters(upperFilter.ToArray()); + + break; + case CharacterCasing.Normal: + break; + } + } + } + + class InputFilterAllLower : InputFilterAllCaps + { + public override Java.Lang.ICharSequence FilterFormatted(Java.Lang.ICharSequence source, int start, int end, ISpanned dest, int dstart, int dend) + { + for (var x = start; x < end; x++) + { + if (char.IsUpper(source.ElementAt(x))) + { + var v = new char[end - start]; + TextUtils.GetChars(source.ToString(), start, end, v, 0); + var s = new string(v).ToLower(CultureInfo.InvariantCulture); + + if (source is ISpanned sourceSpanned) + { + var sp = new SpannableString(s); + TextUtils.CopySpansFrom(sourceSpanned, start, end, null, sp, 0); + return sp; + } + else + { + return new Java.Lang.String(s); + } + } + } + + return null; + } } } diff --git a/src/Uno.UI/UI/Xaml/Controls/TextBox/TextBox.cs b/src/Uno.UI/UI/Xaml/Controls/TextBox/TextBox.cs index 54693cbe048b..066289d2efa7 100644 --- a/src/Uno.UI/UI/Xaml/Controls/TextBox/TextBox.cs +++ b/src/Uno.UI/UI/Xaml/Controls/TextBox/TextBox.cs @@ -98,6 +98,7 @@ private void InitializeProperties() OnTextWrappingChanged(CreateInitialValueChangerEventArgs(TextWrappingProperty, TextWrappingProperty.GetMetadata(GetType()).DefaultValue, TextWrapping)); OnFocusStateChanged((FocusState)FocusStateProperty.GetMetadata(GetType()).DefaultValue, FocusState, initial: true); OnVerticalContentAlignmentChanged(VerticalAlignment.Top, VerticalContentAlignment); + OnTextCharacterCasingChanged(CreateInitialValueChangerEventArgs(CharacterCasingProperty, CharacterCasingProperty.GetMetadata(GetType()).DefaultValue, CharacterCasing)); var buttonRef = _deleteButton?.GetTarget(); @@ -435,6 +436,35 @@ private void OnTextWrappingChanged(DependencyPropertyChangedEventArgs args) #endregion +#if __IOS__ || NET461 || __WASM__ || __SKIA__ || __NETSTD_REFERENCE__ || __MACOS__ + [Uno.NotImplemented("__IOS__", "NET461", "__WASM__", "__SKIA__", "__NETSTD_REFERENCE__", "__MACOS__")] +#endif + public CharacterCasing CharacterCasing + { + get => (CharacterCasing)this.GetValue(CharacterCasingProperty); + set => this.SetValue(CharacterCasingProperty, value); + } + +#if __IOS__ || NET461 || __WASM__ || __SKIA__ || __NETSTD_REFERENCE__ || __MACOS__ + [Uno.NotImplemented("__IOS__", "NET461", "__WASM__", "__SKIA__", "__NETSTD_REFERENCE__", "__MACOS__")] +#endif + public static DependencyProperty CharacterCasingProperty { get; } = + DependencyProperty.Register( + nameof(CharacterCasing), + typeof(CharacterCasing), + typeof(TextBox), + new FrameworkPropertyMetadata( + defaultValue: CharacterCasing.Normal, + propertyChangedCallback: (s, e) => ((TextBox)s)?.OnTextCharacterCasingChanged(e)) + ); + + private void OnTextCharacterCasingChanged(DependencyPropertyChangedEventArgs e) + { + OnTextCharacterCasingChangedPartial(e); + } + + partial void OnTextCharacterCasingChangedPartial(DependencyPropertyChangedEventArgs e); + #region IsReadOnly DependencyProperty public bool IsReadOnly diff --git a/src/Uno.UI/UI/Xaml/Controls/TextBox/TextBox.iOS.cs b/src/Uno.UI/UI/Xaml/Controls/TextBox/TextBox.iOS.cs index 7aef69a11482..219fd279da24 100644 --- a/src/Uno.UI/UI/Xaml/Controls/TextBox/TextBox.iOS.cs +++ b/src/Uno.UI/UI/Xaml/Controls/TextBox/TextBox.iOS.cs @@ -115,7 +115,7 @@ private void UpdateTextBoxView() internal bool OnKey(char key) { var keyRoutedEventArgs = new KeyRoutedEventArgs(this, key.ToVirtualKey()) - { + { CanBubbleNatively = true };