Unverified Commit c8c20fbc authored by chunhtai's avatar chunhtai Committed by GitHub

add read only semantics flag (#34683)

parent 0d9a1b20
20d3861ac8e1f8f38c8659b16b699d0e63db01b1
54f88ab5da4d0f3cff5337ab263dbf3385ee78df
......@@ -832,6 +832,9 @@ class RenderCustomPaint extends RenderProxyBox {
if (properties.textField != null) {
config.isTextField = properties.textField;
}
if (properties.readOnly != null) {
config.isReadOnly = properties.readOnly;
}
if (properties.focused != null) {
config.isFocused = properties.focused;
}
......
......@@ -3426,6 +3426,7 @@ class RenderSemanticsAnnotations extends RenderProxyBox {
bool button,
bool header,
bool textField,
bool readOnly,
bool focused,
bool inMutuallyExclusiveGroup,
bool obscured,
......@@ -3473,6 +3474,7 @@ class RenderSemanticsAnnotations extends RenderProxyBox {
_button = button,
_header = header,
_textField = textField,
_readOnly = readOnly,
_focused = focused,
_inMutuallyExclusiveGroup = inMutuallyExclusiveGroup,
_obscured = obscured,
......@@ -3629,6 +3631,16 @@ class RenderSemanticsAnnotations extends RenderProxyBox {
markNeedsSemanticsUpdate();
}
/// If non-null, sets the [SemanticsNode.isReadOnly] semantic to the given value.
bool get readOnly => _readOnly;
bool _readOnly;
set readOnly(bool value) {
if (readOnly == value)
return;
_readOnly = value;
markNeedsSemanticsUpdate();
}
/// If non-null, sets the [SemanticsNode.isFocused] semantic to the given value.
bool get focused => _focused;
bool _focused;
......@@ -4252,6 +4264,8 @@ class RenderSemanticsAnnotations extends RenderProxyBox {
config.isHeader = header;
if (textField != null)
config.isTextField = textField;
if (readOnly != null)
config.isReadOnly = readOnly;
if (focused != null)
config.isFocused = focused;
if (inMutuallyExclusiveGroup != null)
......
......@@ -565,6 +565,7 @@ class SemanticsProperties extends DiagnosticableTree {
this.button,
this.header,
this.textField,
this.readOnly,
this.focused,
this.inMutuallyExclusiveGroup,
this.hidden,
......@@ -651,6 +652,13 @@ class SemanticsProperties extends DiagnosticableTree {
/// text field.
final bool textField;
/// If non-null, indicates that this subtree is read only.
///
/// Only applicable when [textField] is true
///
/// TalkBack/VoiceOver will treat it as non-editable text field.
final bool readOnly;
/// If non-null, whether the node currently holds input focus.
///
/// At most one node in the tree should hold input focus at any point in time.
......@@ -3506,6 +3514,14 @@ class SemanticsConfiguration {
_setFlag(SemanticsFlag.isTextField, value);
}
/// Whether the owning [RenderObject] is read only.
///
/// Only applicable when [isTextField] is true.
bool get isReadOnly => _hasFlag(SemanticsFlag.isReadOnly);
set isReadOnly(bool value) {
_setFlag(SemanticsFlag.isReadOnly, value);
}
/// Whether the [value] should be obscured.
///
/// This option is usually set in combination with [textField] to indicate
......
......@@ -5919,6 +5919,7 @@ class Semantics extends SingleChildRenderObjectWidget {
bool button,
bool header,
bool textField,
bool readOnly,
bool focused,
bool inMutuallyExclusiveGroup,
bool obscured,
......@@ -5968,6 +5969,7 @@ class Semantics extends SingleChildRenderObjectWidget {
button: button,
header: header,
textField: textField,
readOnly: readOnly,
focused: focused,
inMutuallyExclusiveGroup: inMutuallyExclusiveGroup,
obscured: obscured,
......@@ -6076,6 +6078,7 @@ class Semantics extends SingleChildRenderObjectWidget {
button: properties.button,
header: properties.header,
textField: properties.textField,
readOnly: properties.readOnly,
focused: properties.focused,
liveRegion: properties.liveRegion,
inMutuallyExclusiveGroup: properties.inMutuallyExclusiveGroup,
......@@ -6141,6 +6144,7 @@ class Semantics extends SingleChildRenderObjectWidget {
..button = properties.button
..header = properties.header
..textField = properties.textField
..readOnly = properties.readOnly
..focused = properties.focused
..inMutuallyExclusiveGroup = properties.inMutuallyExclusiveGroup
..obscured = properties.obscured
......
......@@ -412,6 +412,7 @@ void _defineTests() {
hidden: true,
button: true,
textField: true,
readOnly: true,
focused: true,
inMutuallyExclusiveGroup: true,
header: true,
......@@ -458,6 +459,7 @@ void _defineTests() {
hidden: true,
button: true,
textField: true,
readOnly: true,
focused: true,
inMutuallyExclusiveGroup: true,
header: true,
......
......@@ -474,6 +474,7 @@ void main() {
selected: true,
button: true,
textField: true,
readOnly: true,
focused: true,
inMutuallyExclusiveGroup: true,
header: true,
......
......@@ -413,6 +413,7 @@ Matcher matchesSemantics({
bool isButton = false,
bool isFocused = false,
bool isTextField = false,
bool isReadOnly = false,
bool hasEnabledState = false,
bool isEnabled = false,
bool isInMutuallyExclusiveGroup = false,
......@@ -464,6 +465,8 @@ Matcher matchesSemantics({
flags.add(SemanticsFlag.isButton);
if (isTextField)
flags.add(SemanticsFlag.isTextField);
if (isReadOnly)
flags.add(SemanticsFlag.isReadOnly);
if (isFocused)
flags.add(SemanticsFlag.isFocused);
if (hasEnabledState)
......
......@@ -597,6 +597,7 @@ void main() {
isSelected: true,
isButton: true,
isTextField: true,
isReadOnly: true,
hasEnabledState: true,
isFocused: true,
isEnabled: true,
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment