Repository navigation
Description
Current behavior 🐛
Where Uno dispatches pointers itself (every target on master), a UIElement's gesture recognizer gets pointer moves only if the element has a manipulation (a ManipulationMode other than System and a manipulation handler) or CanDrag. An element with only Tapped, DoubleTapped, RightTapped or Holding handlers never sees the finger move between the press and the release. Only the release position is compared with the press position. So:
- Pressing, moving 200 px away and back, then releasing raises
Tapped. - With a
Holdinghandler, pressing and moving 200 px away still raisesHolding(Started) when the hold delay has elapsed, while the finger is 200 px away.
Runtime tests with injected touch on Skia Desktop (Windows), on a stationary 100×100 Border, show it on master at b40e235 and on the branch of #25732, which doesn't change how moves are delivered (the last column was run on that branch only). The input code involved is the same at 4744356.
| Touch input on the element | Only the gesture handler | Same, plus ManipulationMode="System,TranslateX" and a ManipulationStarted handler |
|---|---|---|
Press, move 200 px away and back, release (Tapped handler) |
Tapped raised |
not raised |
Press, move 200 px away, wait 1.5 s (Holding handler) |
Holding Started raised while the finger is away |
not raised |
Expected behavior 🎯
As in WinUI: once the finger has moved out of the tap range, the press is no longer a tap or a hold, even if the finger comes back. Tapped isn't raised on release, and Holding doesn't start. The HoldingState docs say Started is raised when the time threshold is crossed "without the contact being lifted, another contact detected, or another gesture started", and Canceled when "a subsequent gesture (such as a slide) is detected".
WinUI feeds every move of the pointer to the gesture recognizer that tracks the press, whether or not the element has a manipulation:
- On press, the pointer is assigned to an interaction element (
PointerInputProcessor.cppL353): the first element on the branch with tap, double-tap, right-tap or hold enabled, or aManipulationModeother thanSystem(CInputServices::IsInteractionSupported). - Every later message of that pointer, moves included, goes to that element's tracker (
PointerInputProcessor.cppL685-L693), andElementGestureTrackerpasses eachXCP_POINTERUPDATEto the recognizer'sProcessMoveEvents(ElementGestureTracker.cppL508-L527).
How to reproduce it (as minimally and precisely as possible) 🔬
<Grid>
<Border Width="100" Height="100" Background="Red"
HorizontalAlignment="Left" VerticalAlignment="Top"
Tapped="OnTapped" Holding="OnHolding" />
</Grid>private void OnTapped(object sender, TappedRoutedEventArgs e)
=> System.Diagnostics.Debug.WriteLine("Tapped");
private void OnHolding(object sender, HoldingRoutedEventArgs e)
=> System.Diagnostics.Debug.WriteLine($"Holding {e.HoldingState}");On a touch screen:
- Touch the red square, quickly slide 200 px to the right and back without lifting, then lift.
Tappedis logged. - Touch the red square, slide 200 px to the right and keep the finger there for a second.
Holding Startedis logged while the finger is off the square.
Expected, as on WinUI: neither is logged.
Workaround 🛠️
None that's clean. Giving the element a manipulation, as in the last column above, makes Uno feed its recognizer the moves, but the element then also starts manipulations of its own.
Affected platforms 📱💻🖥️
All platforms 🌍: on master, Uno dispatches pointers itself on every target. Reproduced on Desktop (Windows). On servicing/6.8, the same goes for the Skia targets and the native WebAssembly renderer. From the code, 6.8's native Android and iOS renderers aren't affected: there, UIElement.OnPointerMove feeds the recognizer.
Uno.Sdk version (and other relevant versions) 📦
master at 4744356 (Uno 7.0 dev). The same code is on servicing/6.8.
IDE version 🧑💻
N/A
Anything else we need to know? 💬
Where it comes from, at 4744356:
UIElement.OnPointerMovefeeds the recognizer only under#if !UNO_HAS_MANAGED_POINTERS(UIElement.Pointers.csL1208-L1220).- With managed pointers, moves reach a
UIElementrecognizer only through theInputManager(AfterMoveForManipulations), which only knows recognizers registered fromOnRecognizerManipulationStarting(UIElement.Pointers.csL329-L341). ItsUIElementRecognizernotes: "Currently, to avoid any regression for 6.0 SR1, only the move is processed" (L449-L472). ManipulationStartingis raised only when the recognizer creates aManipulation, which it does only if manipulation or drag settings are enabled (GestureRecognizer.csL161-L164,GestureRecognizer.Manipulation.csL180-L181).Tapped,DoubleTapped,RightTappedandHoldinghandlers only enableTap,DoubleTap,RightTapandHold(UIElement.Pointers.csL668-L686).- So
Gesture.ProcessMove, which setsHasMovedOutOfTapRangeand cancels the hold (GestureRecognizer.Gesture.csL79-L93, L209-L240), never runs, andIsTapGesturecompares only the release with the press (L313-L333). The right-tap check usesIsTapGesturetoo.
A fix could register for moves every element whose recognizer tracks the press, not only those with a manipulation. It needn't be costly per move: with #25732, which measures the tap range in window coordinates, a tap- or hold-only recognizer reads only the window position, the pointer identifier, the pressure and the timestamps of a move (Gesture.ProcessMove), so the point can be passed on as is, without a transform per element. The real costs are registering the recognizer on press and unregistering it on release or cancel, and the behavior change: every tap- or hold-only element would then cancel its tap or hold when the finger moves away.
This came up in the review of #25732 (tap range for #25731). It predates that PR. One rare case changes with it: if a parent moves the element with the finger and then stops following it mid-swipe (for example a pager that commits a page), and the finger returns to its starting point before release, master doesn't raise Tapped, #25732 does, and WinUI doesn't. Delivering the moves fixes that case too.
Activity