-
Notifications
You must be signed in to change notification settings - Fork 1.7k
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
Fix gestures in Label Spans #12027
Fix gestures in Label Spans #12027
Conversation
var span = element.FormattedText.Spans[i]; | ||
|
||
var inline = control.Inlines.ElementAt(i); | ||
var startRect = inline.ContentStart.GetCharacterRect(LogicalDirection.Forward); |
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.
Always returning an empty Rect. Reviewing why is happening and possible workarounds.
@jsuarezruiz not sure if you have or havnt, but could you add a test for multiple clickable spans. There was an issue in XF where if you had multiple spans with tap gestures, if you clicked on the last span, all the previous spans tap gestures would also trigger. It was fixed, just want to make sure it doesnt crop back up in MAUI - xamarin/Xamarin.Forms#11650 |
|
@pictos also wondering if tap gestures will be updated in maui to support keyboard accessibility? In XF navigating with a keyboard, tap gestured controls were skipped over. |
Hi @jsuarezruiz thank you for hard work on implementing this one, as well as other things on MAUI. Best regards, |
Pulling this out of draft, need someone to diagnose the failures from the Android API 23 tests. |
src/Controls/samples/Controls.Sample/Pages/Controls/LabelPage.xaml.cs
Outdated
Show resolved
Hide resolved
src/Controls/samples/Controls.Sample/Pages/Controls/LabelPage.xaml.cs
Outdated
Show resolved
Hide resolved
src/Controls/src/Core/Platform/iOS/Extensions/FormattedStringExtensions.cs
Outdated
Show resolved
Hide resolved
src/Controls/src/Core/Platform/iOS/Extensions/FormattedStringExtensions.cs
Show resolved
Hide resolved
src/Controls/src/Core/Platform/iOS/Extensions/FormattedStringExtensions.cs
Outdated
Show resolved
Hide resolved
src/Controls/src/Core/Platform/iOS/Extensions/FormattedStringExtensions.cs
Outdated
Show resolved
Hide resolved
# Conflicts: # src/Controls/samples/Controls.Sample/Pages/Controls/LabelPage.xaml.cs # src/Core/src/PublicAPI/net-ios/PublicAPI.Unshipped.txt # src/Core/src/PublicAPI/net-maccatalyst/PublicAPI.Unshipped.txt
Changes made. Please re-review.
if (platformView == null) | ||
return; | ||
|
||
if (View.GestureRecognizers.Count == 0) | ||
if (View.GestureController.CompositeGestureRecognizers.Count == 0) |
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.
Why this change?
{ | ||
if (Handler is LabelHandler labelHandler && labelHandler.PlatformView is TextBlock textBlock) | ||
{ | ||
_textBlock = textBlock; |
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.
Why do we need the native view change here? can't we look at size changes on the Label itself ? Override Measure or something ?
src/Controls/src/Core/Platform/Windows/Extensions/FormattedStringExtensions.cs
Outdated
Show resolved
Hide resolved
…xaml.cs Co-authored-by: Manuel de la Pena <mandel@microsoft.com>
Thank you for your pull request. We are auto-formating your source code to follow our code guidelines. |
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.
Some comments need to still be addressed and we have some NRE cases in the code.
var heights = new List<double>(); | ||
for (var i = 0; i < formatted.Spans.Count; i++) | ||
{ | ||
var span = formatted.Spans[i]; |
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.
src/Controls/src/Core/Platform/Windows/Extensions/FormattedStringExtensions.cs
Show resolved
Hide resolved
var heights = new List<double>(); | ||
for (var i = 0; i < formatted.Spans.Count; i++) | ||
{ | ||
var span = formatted.Spans[i]; |
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.
Still stands.
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.
The targets seem a bit off on iOS.
Testing this on iOS, I can tap above and below the "Click Me" Label and it changes the colors - for example, I can tap the "Colors" Label above "Click Me" and the event fires.
Same thing with the part that says "Two clickable spans in one line" - I can tap the word "line" and it causes the color change.
This PR affects all platforms, and has quite a few changes here and there. To facilitate its review and have fixes in releases as soon as possible, I am going to close this PR to open smaller PRs focused on each platform. |
Description of Change
Fix gestures in Label Spans.
Android
![fix-gestures-span-droid](https://user-images.githubusercontent.com/6755973/207050457-5123db0d-d8bd-4ad5-8387-9fc3d038d216.gif)
![image](https://user-images.githubusercontent.com/6755973/215065560-fbfc32f0-ea76-4f09-a593-1b213c8c561e.png)
iOS/Catalyst
![fix-gestures-span-ios](https://user-images.githubusercontent.com/6755973/207050447-ab763ffb-fc53-485e-ba30-0cd9835ea4ce.gif)
Windows
(Work in progress)
To test/validate the changes, open the .NET MAUI Gallery and navigate to the Label page. Tap the Span with the text "Click Me". If the Span changes the TextColor, is working as expected.
Issues Fixed
Fixes #4734
Fixes #8004