Skip to content
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

Attach the gestures to the correct (container or platform) view #12108

Merged
merged 15 commits into from
Jan 18, 2023

Conversation

mattleibow
Copy link
Member

@mattleibow mattleibow commented Dec 14, 2022

Description of Change

In Xamarin.Forms, the gestures were attached to the renderer not the actual view. This fixes #8330 because the FrameRenderer code was designed to work with gestures on the render.

In this PR I do 2 things:

  1. _platformView = _handler.ToPlatform(); instead of _platformView = _handler.PlatformView to ensure that we use the container view / renderer.
  2. Make sure to use the _platformView when doing checks because that is what the gesture is attached to.

Issues Fixed

Fixes #8330

Notes

Fixing the gestures like this causes this: #12116

But this is already an issue on Android and Windows... This is a separate issue, but depending on what we decide there determines how we should fix this....

@mattleibow
Copy link
Member Author

How do we even write tests for this...

@mattleibow mattleibow changed the title Use the same platform view with gestures Attach the gestures to the correct (container or platform) view Dec 14, 2022
Comment on lines -81 to +82
handler.SetVirtualView(element);
element.Handler = handler;
handler.SetVirtualView(element);
Copy link
Member Author

@mattleibow mattleibow Dec 15, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@PureWeen I spotted this. In the real code, we set Handler first. It appears that SetVirtualView also sets things, but those need to run later? Not quite sure how this is as setting Handler calls SetVertualView, but SetVirtualView also sets the Handler.

Stepping through the code, I think Handler does all the work as SetVirtualView bails out right away as the first check is:

if (VirtualView == view)
	return;

So not even sure SetVirtualView is needed...

@Redth
Copy link
Member

Redth commented Dec 15, 2022

Will this also help with #7121 ?

@mattleibow
Copy link
Member Author

Will this also help with #7121 ?

Not sure, this PR just fixes iOS. But let me confirm.

@mattleibow
Copy link
Member Author

Will this also help with #7121 ?

Not sure, this PR just fixes iOS. But let me confirm.

It does not, but I think I found the cause and added a comment.

@PureWeen PureWeen merged commit e84098b into main Jan 18, 2023
@PureWeen PureWeen deleted the dev/fix-8330-2 branch January 18, 2023 12:02
@PureWeen
Copy link
Member

/backport to net7.0

@github-actions
Copy link
Contributor

Started backporting to net7.0: https://github.com/dotnet/maui/actions/runs/4016766108

@samhouts samhouts added area-gestures Gesture types and removed area-xaml XAML, CSS, Triggers, Behaviors labels Jul 19, 2023
@github-actions github-actions bot locked and limited conversation to collaborators Dec 13, 2023
@samhouts samhouts added the fixed-in-8.0.0-preview.1.7762 Look for this fix in 8.0.0-preview.1.7762! label Aug 2, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
area-gestures Gesture types fixed-in-8.0.0-preview.1.7762 Look for this fix in 8.0.0-preview.1.7762!
Projects
None yet
Development

Successfully merging this pull request may close these issues.

TapGestureRecognizer not working on a Frame in a grid on iOS or Mac
5 participants