From cc6f86e6e15371b3c2604e96ce40c0577e2dcfa6 Mon Sep 17 00:00:00 2001 From: chunhtai <47866232+chunhtai@users.noreply.github.com> Date: Fri, 9 Jun 2023 12:49:02 -0700 Subject: [PATCH] Clarifies semantics long press and semantics on tap documentation (#128599) fixes https://github.com/flutter/flutter/issues/35112 --- packages/flutter/lib/src/semantics/semantics.dart | 15 +++++++++++++-- packages/flutter/lib/src/widgets/basic.dart | 4 ++++ 2 files changed, 17 insertions(+), 2 deletions(-) diff --git a/packages/flutter/lib/src/semantics/semantics.dart b/packages/flutter/lib/src/semantics/semantics.dart index b3fae67349..1a69a45c8d 100644 --- a/packages/flutter/lib/src/semantics/semantics.dart +++ b/packages/flutter/lib/src/semantics/semantics.dart @@ -1367,8 +1367,13 @@ class SemanticsProperties extends DiagnosticableTree { /// the finger without moving it. For example, a button should implement this /// action. /// - /// VoiceOver users on iOS and TalkBack users on Android can trigger this + /// VoiceOver users on iOS and TalkBack users on Android *may* trigger this /// action by double-tapping the screen while an element is focused. + /// + /// Note: different OSes or assistive technologies may decide to interpret + /// user inputs differently. Some may simulate real screen taps, while others + /// may call semantics tap. One way to handle taps properly is to provide the + /// same handler to both gesture tap and semantics tap. final VoidCallback? onTap; /// The handler for [SemanticsAction.longPress]. @@ -1376,9 +1381,15 @@ class SemanticsProperties extends DiagnosticableTree { /// This is the semantic equivalent of a user pressing and holding the screen /// with the finger for a few seconds without moving it. /// - /// VoiceOver users on iOS and TalkBack users on Android can trigger this + /// VoiceOver users on iOS and TalkBack users on Android *may* trigger this /// action by double-tapping the screen without lifting the finger after the /// second tap. + /// + /// Note: different OSes or assistive technologies may decide to interpret + /// user inputs differently. Some may simulate real long presses, while others + /// may call semantics long press. One way to handle long press properly is to + /// provide the same handler to both gesture long press and semantics long + /// press. final VoidCallback? onLongPress; /// The handler for [SemanticsAction.scrollLeft]. diff --git a/packages/flutter/lib/src/widgets/basic.dart b/packages/flutter/lib/src/widgets/basic.dart index 10f0a538e1..8be37bf513 100644 --- a/packages/flutter/lib/src/widgets/basic.dart +++ b/packages/flutter/lib/src/widgets/basic.dart @@ -6983,6 +6983,8 @@ class MetaData extends SingleChildRenderObjectWidget { /// /// See also: /// +/// * [SemanticsProperties], which contains a complete documentation for each +/// of the constructor parameters that belongs to semantics properties. /// * [MergeSemantics], which marks a subtree as being a single node for /// accessibility purposes. /// * [ExcludeSemantics], which excludes a subtree from the semantics tree @@ -7004,6 +7006,8 @@ class Semantics extends SingleChildRenderObjectWidget { /// /// See also: /// + /// * [SemanticsProperties], which contains a complete documentation for each + /// of the constructor parameters that belongs to semantics properties. /// * [SemanticsSortKey] for a class that determines accessibility traversal /// order. Semantics({