Skip to content
This repository has been archived by the owner on May 1, 2024. It is now read-only.

[Enhancement] span TapGestureRecognizer to work with arabic font! #7655

Closed
msdYqb opened this issue Sep 24, 2019 · 9 comments · Fixed by #13348
Closed

[Enhancement] span TapGestureRecognizer to work with arabic font! #7655

msdYqb opened this issue Sep 24, 2019 · 9 comments · Fixed by #13348
Labels
a/gestures 🖖 a/l10n a/rtl e/6 🕕 6 help wanted We welcome community contributions to any issue, but these might be a good place to start! m/high impact ⬛ p/Android p/iOS 🍎 p/UWP t/bug 🐛 up-for-grabs We welcome community contributions to any issue, but these might be a good place to start!

Comments

@msdYqb
Copy link

msdYqb commented Sep 24, 2019

Summary

span TapGestureRecognizer is not working with Arabic font
when span with Arabic text is tapped in it its either goes to wrong span or nothing happened

API Changes

example

<Label Grid.Row="0" x:Name="allVerses" FlowDirection="RightToLeft" HorizontalTextAlignment="Center">
            </Label>
FormattedString formattedString = new FormattedString();
            var arabic = new List<myClass>
            {
                new myClass{Text = "بعض الكلمات بعض الكلمات بعض الكلمات بعض الكلمات", ID = 1 },
                new myClass{Text = "بعض الكلمات بعض الكلمات بعض الكلمات بعض الكلمات", ID = 2 },
                new myClass{Text = "بعض الكلمات بعض الكلمات بعض الكلمات بعض الكلمات بعض الكلمات بعض الكلمات", ID = 3 },
                new myClass{Text = "بعض الكلمات بعض الكلمات بعض الكلمات", ID = 4 },
            };
            foreach (var text in arabic)
            {
                Span verse = new Span();
                var gesture = new TapGestureRecognizer();
                gesture.Command = Command;
                gesture.CommandParameter = text.ID;
                verse.GestureRecognizers.Add(gesture);
                
                verse.Text = text.Text + " ";
                verse.FontSize = 44;
                verse.ClassId = text.ID.ToString();
                formattedString.Spans.Add(verse);
            }
            allVerses.FormattedText = formattedString;

public Command Command
        {
            get
            {
                return new Command((ID) =>
                {
                    allVerses.FormattedText.Spans.Where(s => s.ClassId == ID.ToString()).First().TextColor = Color.Red;
                });
            }
        }

Intended Use Case

I want to be able to highlight selected span
Screenshot_20190924-203650

@jfversluis
Copy link
Member

Thanks for the issue @msdYqb.

I'm wondering if this is an actual enhancement or this is a bug that should just work. I'm leaning towards the last one. But in either case, I see you've posted some code already, would you be able to put it together in a sample project so we can see what is going on?

@hartez
Copy link
Contributor

hartez commented Sep 24, 2019

I agree with @jfversluis, the recognizers should work with RTL.

@hartez hartez added t/bug 🐛 s/unverified New report that has yet to be verified and removed proposal-open t/enhancement ➕ labels Sep 24, 2019
@hartez
Copy link
Contributor

hartez commented Sep 24, 2019

@msdYqb Are you seeing this problem on Android, iOS, or both?

@msdYqb
Copy link
Author

msdYqb commented Sep 24, 2019

on android and UWP

@msdYqb
Copy link
Author

msdYqb commented Sep 24, 2019

here is example project

thanks guys!
ArabicFormattedStringExample.zip

@msdYqb
Copy link
Author

msdYqb commented Sep 24, 2019

sorry about project name it was to long!

project name fixed
ArabicFS.zip

@StephaneDelcroix
Copy link
Member

thanks

@PureWeen
Copy link
Contributor

PureWeen commented Oct 4, 2019

Looks like this is also an issue on iOS

it's very obvious that the position calculation just needs to be shifted to account for RTL.
When working on this let's look at a general way to express position when set to RTL so other code that needs to calculate location can reuse it

@PureWeen PureWeen moved this from New to Ready For Work in Triage Oct 4, 2019
@PureWeen PureWeen added m/high impact ⬛ and removed s/unverified New report that has yet to be verified labels Oct 4, 2019
@PureWeen PureWeen added this to To do in v4.4.0 via automation Oct 4, 2019
@samhouts samhouts moved this from Ready For Work to Needs Estimate in Triage Oct 4, 2019
@Sauder91
Copy link

Sauder91 commented Dec 6, 2019

I'm seeing this as well on iOS when text wraps. The hashtags in the image below should all be individually tappable, but only the first one works. The same layout with different hash tags sometimes works; its hit or miss. If there is only one it is always selectable though.
Screen Shot 2019-12-06 at 1 31 35 AM

@samhouts samhouts moved this from Needs Estimate to Ready For Work in Triage Jan 3, 2020
@samhouts samhouts added this to To do in iOS Ready For Work Jan 3, 2020
@samhouts samhouts added this to To do in UWP Ready For Work Jan 3, 2020
@samhouts samhouts removed this from Ready For Work in Triage Jan 3, 2020
@samhouts samhouts moved this from To do to To do (high priority) in UWP Ready For Work Feb 18, 2020
@samhouts samhouts moved this from To do to To do-High impact in iOS Ready For Work Jun 1, 2020
@samhouts samhouts moved this from To do to To do-High impact in Android Ready For Work Jun 1, 2020
@samhouts samhouts added inactive Issue is older than 6 months and needs to be retested help wanted We welcome community contributions to any issue, but these might be a good place to start! up-for-grabs We welcome community contributions to any issue, but these might be a good place to start! and removed inactive Issue is older than 6 months and needs to be retested help wanted We welcome community contributions to any issue, but these might be a good place to start! labels Jul 17, 2020
@samhouts samhouts added this to the 5.0.0 milestone Aug 13, 2020
@samhouts samhouts added this to To do in vNext+1 (5.0.0) Aug 14, 2020
@samhouts samhouts added inactive Issue is older than 6 months and needs to be retested help wanted We welcome community contributions to any issue, but these might be a good place to start! and removed inactive Issue is older than 6 months and needs to be retested labels Sep 18, 2020
@samhouts samhouts removed this from the 5.0.0 milestone Nov 2, 2020
Android Ready For Work automation moved this from To do-High impact to Done Jul 7, 2021
iOS Ready For Work automation moved this from To do-High impact to Done Jul 7, 2021
UWP Ready For Work automation moved this from To do-High impact to Done Jul 7, 2021
rmarinho pushed a commit that referenced this issue Jul 7, 2021
…6992 fixes #11650 fixes #7655 fixes #11657 fixes #10520 fixes #4829

* improved span region calculation on android

* Remove unused code

* Nit: clean up comments

* Wrap in ScrollView for small screen compatibility

Co-authored-by: Tim Dittmar <Tim.Dittmar@Exxeta.com>
Co-authored-by: Rachel Kang <rachel.j.kang@gmail.com>
Co-authored-by: Rachel Kang <rachelkang@microsoft.com>
rmarinho added a commit that referenced this issue Sep 20, 2021
* Fix 4143: improved Span region calculation (#13348) fixes #4143 fixes #6992 fixes #11650 fixes #7655 fixes #11657 fixes #10520 fixes #4829 

* improved span region calculation on android

* Remove unused code

* Nit: clean up comments

* Wrap in ScrollView for small screen compatibility

Co-authored-by: Tim Dittmar <Tim.Dittmar@Exxeta.com>
Co-authored-by: Rachel Kang <rachel.j.kang@gmail.com>
Co-authored-by: Rachel Kang <rachelkang@microsoft.com>

* Only check for netfx when not in a wapproj (#14402) fixes #13957

* [macOS] Update Switch renderer (#14334) fixes #14313

* [macOS] Update Switch renderer #14313

* [macOS] Update Switch renderer #14313

* [Android] Fix to Issue Java.Lang.IndexOutOfBoundsException: setSpan (#12764) Fix to Issue #12762

* Update EntryRenderer.cs

Fix to Issue #12762
Java.Lang.IndexOutOfBoundsException: setSpan (nn ... nn) ends beyond length n-1

* Fix to EntryRenderer.cs

* Update EntryRenderer.cs

* Update EntryRenderer.cs

Co-authored-by: Rui Marinho <me@ruimarinho.net>

* [Android] Fix ClearButton not working when changing the ClearButtonVisibility while the Entry field is focused (#13820) Fixes #13819

Co-authored-by: Javier Suárez <javiersuarezruiz@hotmail.com>

* Automated dotnet-format update (#14404)

Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>

* Automated dotnet-format update (#14405)

Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>

* fix memory leak (and some crashes) in ItemsViewController (iOS) (#14111)

* add unit test

* fix memory leak (and some crashes) in ItemsViewController (iOS)

* Update ItemsViewController.cs

Co-authored-by: Rui Marinho <me@ruimarinho.net>

* Enable ScrollTo tests for Android, UWP; implement ScrollTo with group index for Android (#13007)

* Remove inaccurate category

* Enable ScrollTo tests for Android/UWP; Implement grouped ScrollTo for Android

* Implement missing ScrollTo grouped item by index

* Exempt 3788 test from UWP

* Ignore test on UWP

Co-authored-by: Rui Marinho <me@ruimarinho.net>

* Fix type for case blueviolet (#14434)

The 'v' in this case was uppercase causing this typeconverter to reject BlueViolet as a valid color value. Fixes #AB1286706 [XVS]XLS0431: Invalid value for property 'BackgroundColor': 'BlueViolet'

* [iOS] Fix: CollectionView was not updating when it was invisible (#14384)

* [iOS] Fix: CollectionView was not updating when it was invisible

* [iOS] Fix: NSInternalInconsistencyException Reason: request for number of items in section X when there are only X sections in the collection view when NumberOfItemsInSection is invoked

* Revert "[iOS] Fix: NSInternalInconsistencyException Reason: request for number of items in section X when there are only X sections in the collection view when NumberOfItemsInSection is invoked"

This reverts commit 2343f15.

* [iOS] Fix: Prevent NumberOfItemsInSection invoking if CollectionView is hidded to avoid  "NSInternalInconsistencyException Reason: request for number of items in section X when there are only X sections"

* [iOS] Scroll locked issue using SwipeView (#12758)

* Fixed issue re-enabling the scroll

* Added repro sample

* Fixed also the swipe sensitive issue on iOS

Co-authored-by: Gerald Versluis <gerald.versluis@microsoft.com>

* Fix removed shadow in Thumb setting a custom color (#13166)

* [iOS] Fix crash/closing wrong modal with FormSheet and tap outside (#14527)

* Add repro + fix

* Update Issue12300.cs

* [Core] SwipeItem Parent using SwipeView in DataTemplate (#13385)

* Added repro sample

* Fix the issue

Co-authored-by: Gerald Versluis <gerald.versluis@microsoft.com>

* Fix Frame Background issue with transparent color (#14565)

* Fix broken disabled Button visual state in UWP (#14567)

Co-authored-by: Gerald Versluis <gerald.versluis@microsoft.com>

* Update Device.Idiom when flipping tablet mode state (#13150)

* [Android] Fix occasional wrong touch interception in SwipeView Content  (#13732)

* Fix wrong touch interception in SwipeView Content on Android

* Updated swipe delta

* Fix Entry issue using TextColor and ClearButton in iOS < 13 (#14566)

Co-authored-by: Gerald Versluis <gerald.versluis@microsoft.com>

* Fix issue using FormattedString and LineBreakMode on iOS (#14572)

Co-authored-by: Gerald Versluis <gerald.versluis@microsoft.com>

* Align BarBackground behavior between Android and iOS. (#13503)

* Automated dotnet-format update (#14570)

Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>

* [Android] Update gradients based on offset changes in Frame and BoxView (#11812)

* Update gradients based on offset changes in Frame and BoxView on Android

* Updated the sample to test also the BoxView Brush offsets

* Fix NRE in ListView Command validation (#14580)

* [iOS] Fix inability to check an initially disabled RadioButton after enabling it (#14545)

* Listen for updates to IsEnabled on RadioButton to ensure that the tap gesture recogniser is added when the control is enabled

* Update Issue14544.cs

* Update test case

Co-authored-by: Gerald Versluis <gerald@verslu.is>

* Fix crash navigating in Shell (#14577)

* Androidx bumps (#14506)

* Update to Latest Android X Libraries

* - fix android forwarders

* Moar updates

Co-authored-by: Gerald Versluis <gerald@verslu.is>

* Validate issue 14433 (#14576)

* Added repro sample

* Updated sample

Co-authored-by: Gerald Versluis <gerald.versluis@microsoft.com>

* [iOS] Remove usage of System.Drawing types (#14571)

* Run nightly also for 5.0.0 branch

* Automated dotnet-format update (#14581)

Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>

* Ordering children while adding (#8231)

* Ordering children while adding

* Abstract OrderElement

* Re-order on runtime child addition and Tests

* Runtime addition ensures Z Index

* Stop performance measurement on return

* Update VisualElementPackager.cs

Co-authored-by: Gerald Versluis <gerald@verslu.is>
Co-authored-by: Javier Suárez <javiersuarezruiz@hotmail.com>

* If stroke is null avoid render a shape stroke (#14587)

* Fix broken Android platform tests (#14590)

* Automated dotnet-format update (#14595)

Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>

* [macOS] Fix RadioButton activated behaviour (#14139)

* Respond to Activated event

* Set initial control state based on element state

* Revert "Set initial control state based on element state"

This reverts commit 1bd1238.

* CollectionView RemainingItemsThreshold implementation for UWP (#14202)

* [Android] Fix building with Android stable bits (#14608)

* Set java sdk path

* Use class-parse

Co-authored-by: Braini01 <T_Dittmar@web.de>
Co-authored-by: Tim Dittmar <Tim.Dittmar@Exxeta.com>
Co-authored-by: Rachel Kang <rachel.j.kang@gmail.com>
Co-authored-by: Rachel Kang <rachelkang@microsoft.com>
Co-authored-by: Matthew Leibowitz <mattleibow@live.com>
Co-authored-by: MH Rastegari <42671084+mhrastegary77@users.noreply.github.com>
Co-authored-by: Felipe Silveira <felipe@transis.com.br>
Co-authored-by: Rui Marinho <me@ruimarinho.net>
Co-authored-by: Jonathan Goyvaerts <jonathan.goyvaerts@gmail.com>
Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
Co-authored-by: Thomas Mijieux <tmijieux@users.noreply.github.com>
Co-authored-by: E.Z. Hart <hartez@users.noreply.github.com>
Co-authored-by: Marco Goertz <mgoertz@microsoft.com>
Co-authored-by: Kirill <rotorgames@bk.ru>
Co-authored-by: Gerald Versluis <gerald.versluis@microsoft.com>
Co-authored-by: Lee Millward <lee.millward@gmail.com>
Co-authored-by: Gerald Versluis <gerald@verslu.is>
Co-authored-by: Shane Neuville <shneuvil@microsoft.com>
Co-authored-by: Filip Navara <filip.navara@gmail.com>
Co-authored-by: Shanmukha Ranganath <shanmukharanganath@gmail.com>
Co-authored-by: Julio César Rocha <JunielKatarn@users.noreply.github.com>
Co-authored-by: nk221 <kirill.n@gmail.com>
rotorgames pushed a commit to rotorgames/Xamarin.Forms that referenced this issue Aug 19, 2022
…rin#4143 fixes xamarin#6992 fixes xamarin#11650 fixes xamarin#7655 fixes xamarin#11657 fixes xamarin#10520 fixes xamarin#4829

* improved span region calculation on android

* Remove unused code

* Nit: clean up comments

* Wrap in ScrollView for small screen compatibility

Co-authored-by: Tim Dittmar <Tim.Dittmar@Exxeta.com>
Co-authored-by: Rachel Kang <rachel.j.kang@gmail.com>
Co-authored-by: Rachel Kang <rachelkang@microsoft.com>
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
a/gestures 🖖 a/l10n a/rtl e/6 🕕 6 help wanted We welcome community contributions to any issue, but these might be a good place to start! m/high impact ⬛ p/Android p/iOS 🍎 p/UWP t/bug 🐛 up-for-grabs We welcome community contributions to any issue, but these might be a good place to start!
Projects
v4.4.0
  
To do
Development

Successfully merging a pull request may close this issue.

7 participants