提交 1787c3fb 编写于 作者: M Michael Goderbauer 提交者: GitHub

Adding SemanticsFlag.isSelected (#3764)

* Adding SemanticsFlag.isSelected

* typo
上级 b91d2f1b
......@@ -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;
}
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册