-
Notifications
You must be signed in to change notification settings - Fork 1.8k
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
Add property for tapping on page to close soft input keyboard #16530
Conversation
/rebase |
301d2be
to
013b563
Compare
9c60409
to
6539b09
Compare
Context: https://github.com/jonathanpeppers/memory-analyzers Context: https://www.nuget.org/packages/MemoryAnalyzers/0.1.0-beta.3 This adds a new Roslyn analyzer that warns about the following cases. ## MA0001 Don't define `public` events in `NSObject` subclasses: ```csharp public class MyView : UIView { // NOPE! public event EventHandler MyEvent; } ``` ## MA0002 Don't declare members in `NSObject` subclasses unless they are: * `WeakReference` or `WeakReference<T>` * Value types ```csharp class MyView : UIView { // NOPE! public UIView? Parent { get; set; } public void Add(MyView subview) { subview.Parent = this; AddSubview(subview); } } ``` ## MA0003 Don't subscribe to events inside `NSObject` subclasses unless: * It's your event via `this.MyEvent` or from a base type. * The method is `static`. ```csharp class MyView : UIView { public MyView() { var picker = new UIDatePicker(); AddSubview(picker); picker.ValueChanged += OnValueChanged; } void OnValueChanged(object sender, EventArgs e) { } // Use this instead and it doesn't leak! //static void OnValueChanged(object sender, EventArgs e) { } } ``` This is also on NuGet, but I just commited the package until we can get it added to the `dotnet-public` feed. Places with PRs in flight are marked with: [UnconditionalSuppressMessage("Memory", "MA0002", Justification = "FIXME: #16530")] A few are marked as "not an issue" with an explanation. Others mention a test with a proof they are OK. A few places I could actually *remove* `UnconditionalSuppressMessage` where I could improve the analyzer to ignore that case.
/rebase |
# Conflicts: # src/Controls/src/Core/PublicAPI/net-tizen/PublicAPI.Unshipped.txt # src/Core/src/Platform/iOS/ResignFirstResponderTouchGestureRecognizer.cs
🚨 API change(s) detected @davidbritch FYI |
@PureWeen The Entry should have an event or command indicating that the soft keyboard has been turned off. The key is that after the soft keyboard is turned off, the Entry needs to verify the input data. Using the Unfocused event in Xamarin But how to implement it in MAUI |
@PureWeen In Xamarin, Entry did ultimately capture the focus, but after the soft keyboard disappeared, Unfocused was triggered for verification The point is not the focus, but Entry needs to know that the soft keyboard is turned off in order to verify the data. The core issue is that Entry needs to know that the keyboard has been turned off. |
The feature "HideSoftInputOnTapped" isn't working anymore in the version 8.0.100-rc.2.23502.2 for iOS & Android Anyone confirm this too? |
@Bruno2049 In .NET 8 there's a if (entry.IsSoftInputShowing())
await entry.HideSoftInputAsync(System.Threading.CancellationToken.None); |
@davidbritch Ok, but to use that method I need to listen for the Tap gesture in Page. |
@Bruno2049 I've just tried this on Android and iOS in .NET 8 RC2 with an <ContentPage xmlns="http://schemas.microsoft.com/dotnet/2021/maui"
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
x:Class="ContentPageTest.MainPage"
HideSoftInputOnTapped="True">
<VerticalStackLayout Margin="20"
Spacing="6">
<HorizontalStackLayout>
<Label Text="Toggle HideSoftInputOnTapped"
VerticalTextAlignment="Center" />
<CheckBox x:Name="checkBox"
IsChecked="True"
CheckedChanged="OnCheckBoxCheckedChanged" />
</HorizontalStackLayout>
<Label Text="Tap page and soft input keyboard should close." />
<Entry x:Name="entry"
Placeholder="Focus here" />
</VerticalStackLayout>
</ContentPage> void OnCheckBoxCheckedChanged(System.Object sender, Microsoft.Maui.Controls.CheckedChangedEventArgs e)
{
HideSoftInputOnTapped = e.Value;
} |
HideSoftInputOnTapped do not work. |
Log an issue with a repro please |
Description of Change
When set to true on the
ContentPage
the soft input will hide whenever you tap anywhere on the screen. This behavior is most likely counter intuitive and not how typical platform app operates. If you're adding this to your app it will most likely confuse your user. This was the default behavior in Xamarin.Forms so we need a way to toggle this for users migrating.Issues Fixed
Fixes #12003
Fixes #11703
Fixes #12002