-
Notifications
You must be signed in to change notification settings - Fork 1.9k
[Android] Prevent Picker from Gaining Focus on Touch #29068
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
Merged
PureWeen
merged 6 commits into
dotnet:inflight/current
from
bhavanesh2001:android_picker_cleanup
Jun 19, 2025
Merged
Changes from 3 commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
eb3a4db
make picker not focisable
bhavanesh2001 54e8948
Address review comments
bhavanesh2001 cb231e9
set keylistner to null
bhavanesh2001 c4b41db
Make sure Focus()/Unfocus() works
bhavanesh2001 a6d3e6d
Address review comments
bhavanesh2001 e30f84d
Remove IsFocused Checks
bhavanesh2001 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -2,6 +2,7 @@ | |
| using Android.Content; | ||
| using Android.Runtime; | ||
| using Android.Text; | ||
| using Android.Text.Method; | ||
| using Android.Util; | ||
| using Android.Views; | ||
| using AndroidX.AppCompat.Widget; | ||
|
|
@@ -31,6 +32,8 @@ protected MauiDatePicker(IntPtr javaReference, JniHandleOwnership transfer) : ba | |
| { | ||
| } | ||
|
|
||
| protected override IMovementMethod? DefaultMovementMethod => null; | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Can we comment the three places we are doing this with why we are doing this? Indicate that according to the docs this MovementMethod is purely related to moving the cursor inside the box but since the text is readonly we remove it to avoid cursor related keyboard navigation? |
||
|
|
||
| public Action? ShowPicker { get; set; } | ||
| public Action? HidePicker { get; set; } | ||
|
|
||
|
|
@@ -44,10 +47,7 @@ void Initialize() | |
| if (Background != null) | ||
| DrawableCompat.Wrap(Background); | ||
|
|
||
| Focusable = true; | ||
| FocusableInTouchMode = false; | ||
| Clickable = true; | ||
| InputType = InputTypes.Null; | ||
| PickerManager.Init(this); | ||
|
|
||
| SetOnClickListener(this); | ||
| } | ||
|
|
||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1 +1,8 @@ | ||
| #nullable enable | ||
| *REMOVED*Microsoft.Maui.Platform.MauiPicker.ShowPopupOnFocus.get -> bool | ||
| *REMOVED*Microsoft.Maui.Platform.MauiPicker.ShowPopupOnFocus.set -> void | ||
| *REMOVED*override Microsoft.Maui.Platform.MauiPicker.OnFocusChanged(bool gainFocus, Android.Views.FocusSearchDirection direction, Android.Graphics.Rect? previouslyFocusedRect) -> void | ||
| *REMOVED*override Microsoft.Maui.Platform.MauiPicker.OnTouchEvent(Android.Views.MotionEvent? e) -> bool | ||
| override Microsoft.Maui.Platform.MauiDatePicker.DefaultMovementMethod.get -> Android.Text.Method.IMovementMethod? | ||
| override Microsoft.Maui.Platform.MauiPickerBase.DefaultMovementMethod.get -> Android.Text.Method.IMovementMethod? | ||
| override Microsoft.Maui.Platform.MauiTimePicker.DefaultMovementMethod.get -> Android.Text.Method.IMovementMethod? |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We will probably want to add some extra code to make sure this test still passes
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Although I think firing Focus/Unfocus events based on dialog show/dismiss is questionable, I wired up mappers for Focus() and Unfocus() calls to ensure they still work.