Skip to content

Tapped and Holding ignore finger moves unless the element has a manipulation #25805

Open

Description

@mikernet

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 Holding handler, pressing and moving 200 px away still raises Holding (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:

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:

  1. Touch the red square, quickly slide 200 px to the right and back without lifting, then lift. Tapped is logged.
  2. Touch the red square, slide 200 px to the right and keep the finger there for a second. Holding Started is 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:

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions