From 2a81391915a5b223279f117d9143ed483b8482e4 Mon Sep 17 00:00:00 2001 From: Ian Hickson Date: Fri, 16 Sep 2016 23:22:20 -0700 Subject: [PATCH] Some semantics documentation. (#5922) --- .../flutter/lib/src/rendering/semantics.dart | 44 +++++++++++++++++++ 1 file changed, 44 insertions(+) diff --git a/packages/flutter/lib/src/rendering/semantics.dart b/packages/flutter/lib/src/rendering/semantics.dart index 69f4857137..02f9764c18 100644 --- a/packages/flutter/lib/src/rendering/semantics.dart +++ b/packages/flutter/lib/src/rendering/semantics.dart @@ -13,14 +13,53 @@ import 'package:vector_math/vector_math_64.dart'; import 'node.dart'; +/// The possible actions that can be conveyed from the operating system +/// accessibility APIs to a [SemanticsNode] object. enum SemanticAction { + /// The equivalent of a user briefly tapping the screen with the finger + /// without moving it. tap, + + /// The equivalent of a user pressing and holding the screen with the finger + /// for a few seconds without moving it. longPress, + + /// The equivalent of a user moving their finger across the screen from right + /// to left. + /// + /// This action should be recognized by controls that are horizontally + /// scrollable. scrollLeft, + + /// The equivalent of a user moving their finger across the screen from left + /// to right. + /// + /// This action should be recognized by controls that are horizontally + /// scrollable. scrollRight, + + /// The equivalent of a user moving their finger across the screen from + /// bottom to top. + /// + /// This action should be recognized by controls that are vertically + /// scrollable. scrollUp, + + /// The equivalent of a user moving their finger across the screen from top + /// to bottom. + /// + /// This action should be recognized by controls that are vertically + /// scrollable. scrollDown, + + /// A request to increase the value represented by the [SemanticsNode]. + /// + /// For example, this action might be recognized by a slider control. increase, + + /// A request to decrease the value represented by the [SemanticsNode]. + /// + /// For example, this action might be recognized by a slider control. decrease, } @@ -32,6 +71,11 @@ enum SemanticAction { /// [SemanticsNode.canBeTapped] is true, [handleSemanticScrollDown]() will only /// be called if [SemanticsNode.canBeScrolledVertically] is true, etc). abstract class SemanticActionHandler { // ignore: one_member_abstracts + /// Called when the object implementing this interface receives a + /// [SemanticAction]. For example, if the user of an accessibility tool + /// instructs their device that they wish to tap a button, the [RenderObject] + /// behind that button would have its [performAction] method called with the + /// [SemanticAction.tap] action. void performAction(SemanticAction action); }