Adding SemanticsFlag.isSelected (flutter/engine#3764)
* Adding SemanticsFlag.isSelected * typo
This commit is contained in:
committed by
GitHub
parent
923bb8cc3b
commit
89ab65beea
@@ -112,6 +112,7 @@ class SemanticsAction {
|
||||
class SemanticsFlags {
|
||||
static const int _kHasCheckedStateIndex = 1 << 0;
|
||||
static const int _kIsCheckedIndex = 1 << 1;
|
||||
static const int _kIsSelectedIndex = 1 << 2;
|
||||
|
||||
const SemanticsFlags._(this.index);
|
||||
|
||||
@@ -133,12 +134,22 @@ class SemanticsFlags {
|
||||
/// For example, if a checkbox has a visible checkmark, [isChecked] is true.
|
||||
static const SemanticsFlags isChecked = const SemanticsFlags._(_kIsCheckedIndex);
|
||||
|
||||
|
||||
/// Whether a semantics node is selected.
|
||||
///
|
||||
/// If true, the semantics node is "selected". If false, the semantics node is
|
||||
/// "unselected".
|
||||
///
|
||||
/// For example, the active tab in a tab bar has [isSelected] set to true.
|
||||
static const SemanticsFlags isSelected = const SemanticsFlags._(_kIsSelectedIndex);
|
||||
|
||||
/// The possible semantics flags.
|
||||
///
|
||||
/// The map's key is the [index] of the flag and the value is the flag itself.
|
||||
static final Map<int, SemanticsFlags> values = const <int, SemanticsFlags>{
|
||||
_kHasCheckedStateIndex: hasCheckedState,
|
||||
_kIsCheckedIndex: isChecked,
|
||||
_kIsSelectedIndex: isSelected,
|
||||
};
|
||||
|
||||
@override
|
||||
@@ -148,6 +159,8 @@ class SemanticsFlags {
|
||||
return 'SemanticsFlags.hasCheckedState';
|
||||
case _kIsCheckedIndex:
|
||||
return 'SemanticsFlags.isChecked';
|
||||
case _kIsSelectedIndex:
|
||||
return 'SemanticsFlags.isSelected';
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
@@ -31,6 +31,7 @@ enum class SemanticsAction : int32_t {
|
||||
enum class SemanticsFlags : int32_t {
|
||||
kHasCheckedState = 1 << 0,
|
||||
kIsChecked = 1 << 1,
|
||||
kIsSelected = 1 << 2,
|
||||
};
|
||||
|
||||
struct SemanticsNode {
|
||||
|
||||
@@ -48,6 +48,7 @@ class AccessibilityBridge extends AccessibilityNodeProvider {
|
||||
|
||||
private static final int SEMANTICS_FLAG_HAS_CHECKED_STATE = 1 << 0;
|
||||
private static final int SEMANTICS_FLAG_IS_CHECKED = 1 << 1;
|
||||
private static final int SEMANTICS_FLAG_IS_SELECTED = 1 << 2;
|
||||
|
||||
AccessibilityBridge(FlutterView owner) {
|
||||
assert owner != null;
|
||||
@@ -119,6 +120,7 @@ class AccessibilityBridge extends AccessibilityNodeProvider {
|
||||
|
||||
result.setCheckable((object.flags & SEMANTICS_FLAG_HAS_CHECKED_STATE) != 0);
|
||||
result.setChecked((object.flags & SEMANTICS_FLAG_IS_CHECKED) != 0);
|
||||
result.setSelected((object.flags & SEMANTICS_FLAG_IS_SELECTED) != 0);
|
||||
result.setText(object.label);
|
||||
|
||||
// TODO(ianh): use setTraversalBefore/setTraversalAfter to set
|
||||
|
||||
@@ -116,6 +116,10 @@ blink::SemanticsAction GetSemanticsActionForScrollDirection(
|
||||
_node.HasAction(blink::SemanticsAction::kDecrease)) {
|
||||
traits |= UIAccessibilityTraitAdjustable;
|
||||
}
|
||||
if (_node.HasFlag(blink::SemanticsFlags::kIsSelected) ||
|
||||
_node.HasFlag(blink::SemanticsFlags::kIsChecked)) {
|
||||
traits |= UIAccessibilityTraitSelected;
|
||||
}
|
||||
return traits;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user