public sealed class GestureRecognizerTurns a stream of pointer events into taps, long presses and drags.
No guide page documents this yet — the page shows what the code says about itself.
Remarks
Time arrives on the event rather than from a clock this reads. A recogniser that calls DateTime.Now cannot be tested without sleeping, cannot replay a recorded input trace, and behaves differently when a breakpoint holds the frame — and the caller already knows what time the input happened, which is more accurate than what time this got round to looking.
Every gesture goes to the element the press landed on, for its whole life, however far the pointer travels afterwards. That is the same rule as pointer capture and it is here for the same reason: a drag that leaves the scrollbar it started on must keep reaching the scrollbar. They coexist rather than duplicate — capture redirects the raw pointer events, this remembers the target of a gesture already in progress.
One pointer produces taps, long presses and drags; two produce a transform. State is kept per pointer id, so two fingers on two different controls are two independent gestures — which is right. Two fingers that start moving relative to each other become one TransformEvent instead, and the drags they had already begun are Cancelled rather than left running: a map that both panned and zoomed from the same two fingers would move twice as far as either gesture asked for.
⚠ Two, not more. A third finger arriving during a transform is ignored rather than folded in — the two that started it keep it. Three-finger gestures are a separate idea with no agreed meaning across platforms, and averaging an arbitrary number of pointers into one scale is the kind of approximation that is worse than the gap.
Fields and properties (1)
public GestureSettings SettingsThe thresholds it recognises against.
Methods (5)
public GestureRecognizer(GestureSettings? settings = null)Creates a recogniser.
public void Process(PointerEvent args, UiElement? target)Feeds it a pointer event.
public void Tick(TimeSpan now)Tells it what time it is, so that a press that is not going anywhere can become a long one.
public void EndTapRun()Ends the current run of taps, so that the next one counts as the first.
public bool Cancel(int pointerId)Gives up on a pointer, because something else took it.
Used by (9)
- ShellHelloUi
- AdvancedFixtureVixen.Ui.Controls.Advanced.Tests
- GestureTestsVixen.Ui.Tests
- NumericInputVixen.Ui.Controls
- TreeViewVixen.Ui.Controls.Advanced
- UiDocumentVixen.Ui
- AssetGridVixen.Editor.App
- EditorAffordanceTestsVixen.Editor.App.Tests
- EditorShellVixen.Editor.Ui