-
Notifications
You must be signed in to change notification settings - Fork 669
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
Proposal: Add Method to Hit Test and Manually Transfer Clicks (like in Android & iOS) #9667
Comments
Hi I'm an AI powered bot that finds similar issues based off the issue title. Please view the issues below to see if they solve your problem, and if the issue describes your problem please consider closing this one. Thank you! Open similar issues:
|
Hi, have you seen the API Microsoft.UI.Xaml.Media.VisualTreeHelper.FindElementsInHostCoordinates? It might help you here. Thanks! |
Thank you, that is interesting. I wasn't aware of that. Maui actually has a built in cross-platform function like this as well:
And one can deconstruct and alter the code easily enough that it uses in each platform. The problem is not being able to find what is at a given coordinate, but rather deciding whether or not the component (or another over/under or simultaneous peripherally) should receive the click or be activated by it. We have no way to control this in Windows. We cannot Nor can we return a custom element vs. decide to invoke That is where the WinUI3 deficit is. If I am managing my own nested carousels made from basic Maui Layout/Image elements for example with 2D click and drag functions, I can determine in iOS and Android if the click is made in this region, and manipulate the elements myself based on this and the click data. Or if I want a click to go straight through to a native text editor field, I can allow this and not interfere. Such management is not possible in WinUI3, because we have no access to the ongoing touches/clicks and cannot pass through clicks selectively to the native element management. All of those things are possible in Android and iOS for what I think are very good reasons. Hopefully that makes sense. Please let me know if not. Thanks. |
Thanks for the response, it makes sense. We'll leave this open and consider it in the future. Thanks! |
Proposal: Add Method to Hit Test and Manually Transfer Clicks (like in Android & iOS)
Summary
Currently there is no way in WinUI C# to hit test a click and then decide what to do based on the hit test (eg. let the platform activate the given clicked element, transfer the click to another element, or run some other function).
In Android .NET and iOS .NET there are working methods for this, but no such methods exist in WinUI3. Adding proper methods will allow more unified coding experiences with .NET MAUI and general modern designs. It will bring WinUI3 up to standard with the other OS's.
Rationale
.NET MAUI is supposed to represent a unified platform for development for Android, iOS, and WinUI3. Yet this major function is missing from WinUI3 disallowing us to build unified experiences where clicks can be custom managed across platforms.
WinUI3 should be brought up to spec with Android & iOS so it has a comparable feature set for custom and more advanced management of user click events. This will allow, for example, management of custom nested carousels or the creation of overlapping clickable objects with complex rules.
To illustrate:
1) In Android .NET:
touchView.Touch += FunctionToRunOnTouch
MotionEvent
.e.Handled = true;
if done with it.MotionEvent clonedEvent = MotionEvent.Obtain(e.Event)
pickedView.DispatchTouchEvent(clonedEvent)
2) In iOS .NET:
public override UIView HitTest(CGPoint point, UIEvent uievent)
which returns the UIView that should receive the click.base.HitTest()
within this invokes the default behavior.TouchesBegan
,TouchesCancelled
,TouchesMoved
&TouchesEnded
which then lets us track the touch data for each touch as an array ofUITouch
objects on each update.3) In WinUI3:
Scope
The text was updated successfully, but these errors were encountered: