Skip to content

Commit

Permalink
A11y cursor movements for text fields on Android (flutter#4419)
Browse files Browse the repository at this point in the history
* a11y cursor movement by character

* focus fixes

* doc fixes
  • Loading branch information
goderbauer authored Dec 6, 2017
1 parent f888186 commit fb44dce
Show file tree
Hide file tree
Showing 3 changed files with 183 additions and 75 deletions.
19 changes: 19 additions & 0 deletions lib/ui/semantics.dart
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@ class SemanticsAction {
static const int _kIncreaseIndex = 1 << 6;
static const int _kDecreaseIndex = 1 << 7;
static const int _kShowOnScreen = 1 << 8;
static const int _kMoveCursorForwardByCharacter = 1 << 9;
static const int _kMoveCursorBackwardByCharacter = 1 << 10;

/// The numerical value for this action.
///
Expand Down Expand Up @@ -76,6 +78,17 @@ class SemanticsAction {
/// is partially off screen to bring it on screen.
static const SemanticsAction showOnScreen = const SemanticsAction._(_kShowOnScreen);


/// Move the cursor forward by one character.
///
/// This is for example used by the cursor control in text fields.
static const SemanticsAction moveCursorForwardByCharacter = const SemanticsAction._(_kMoveCursorForwardByCharacter);

/// Move the cursor backward by one character.
///
/// This is for example used by the cursor control in text fields.
static const SemanticsAction moveCursorBackardByCharacter = const SemanticsAction._(_kMoveCursorBackwardByCharacter);

/// The possible semantics actions.
///
/// The map's key is the [index] of the action and the value is the action
Expand All @@ -90,6 +103,8 @@ class SemanticsAction {
_kIncreaseIndex: increase,
_kDecreaseIndex: decrease,
_kShowOnScreen: showOnScreen,
_kMoveCursorForwardByCharacter: moveCursorForwardByCharacter,
_kMoveCursorBackwardByCharacter: moveCursorBackardByCharacter,
};

@override
Expand All @@ -113,6 +128,10 @@ class SemanticsAction {
return 'SemanticsAction.decrease';
case _kShowOnScreen:
return 'SemanticsAction.showOnScreen';
case _kMoveCursorForwardByCharacter:
return 'SemanticsAction.moveCursorForwardByCharacter';
case _kMoveCursorBackwardByCharacter:
return 'SemanticsAction.moveCursorBackardByCharacter';
}
return null;
}
Expand Down
Loading

0 comments on commit fb44dce

Please sign in to comment.