From 46ed99bb958ddb32cbf1bee2fcfb7b328bcbe0ab Mon Sep 17 00:00:00 2001 From: Arnold Loubriat Date: Sun, 15 Dec 2024 21:43:58 +0100 Subject: [PATCH] feat: Expose the `is_required` property (#497) --- consumer/src/node.rs | 4 ++++ platforms/atspi-common/src/node.rs | 3 +++ platforms/macos/src/node.rs | 7 +++++++ platforms/windows/src/node.rs | 7 ++++++- 4 files changed, 20 insertions(+), 1 deletion(-) diff --git a/consumer/src/node.rs b/consumer/src/node.rs index 13e86ac9..a9c2c1a5 100644 --- a/consumer/src/node.rs +++ b/consumer/src/node.rs @@ -609,6 +609,10 @@ impl<'a> Node<'a> { ) } + pub fn is_required(&self) -> bool { + self.data().is_required() + } + pub fn live(&self) -> Live { self.data() .live() diff --git a/platforms/atspi-common/src/node.rs b/platforms/atspi-common/src/node.rs index 994dfc03..5a0979d2 100644 --- a/platforms/atspi-common/src/node.rs +++ b/platforms/atspi-common/src/node.rs @@ -294,6 +294,9 @@ impl NodeWrapper<'_> { if state.is_focusable() { atspi_state.insert(State::Focusable); } + if state.is_required() { + atspi_state.insert(State::Required); + } if let Some(orientation) = state.orientation() { atspi_state.insert(if orientation == Orientation::Horizontal { State::Horizontal diff --git a/platforms/macos/src/node.rs b/platforms/macos/src/node.rs index 49a5f791..6c336432 100644 --- a/platforms/macos/src/node.rs +++ b/platforms/macos/src/node.rs @@ -807,6 +807,12 @@ declare_class!( }); } + #[method(isAccessibilityRequired)] + fn is_required(&self) -> bool { + self.resolve(|node| node.is_required()) + .unwrap_or(false) + } + #[method(isAccessibilitySelectorAllowed:)] fn is_selector_allowed(&self, selector: Sel) -> bool { self.resolve(|node| { @@ -860,6 +866,7 @@ declare_class!( || selector == sel!(accessibilityValue) || selector == sel!(accessibilityMinValue) || selector == sel!(accessibilityMaxValue) + || selector == sel!(isAccessibilityRequired) || selector == sel!(accessibilityOrientation) || selector == sel!(isAccessibilityElement) || selector == sel!(isAccessibilityFocused) diff --git a/platforms/windows/src/node.rs b/platforms/windows/src/node.rs index cae2b1a4..524f2363 100644 --- a/platforms/windows/src/node.rs +++ b/platforms/windows/src/node.rs @@ -374,6 +374,10 @@ impl NodeWrapper<'_> { .unwrap_or_else(|| self.numeric_value_step()) } + fn is_required(&self) -> bool { + self.0.is_required() + } + fn is_selection_item_pattern_supported(&self) -> bool { match self.0.role() { // TODO: tables (#29) @@ -885,7 +889,8 @@ properties! { (LiveSetting, live_setting), (AutomationId, automation_id), (ClassName, class_name), - (Orientation, orientation) + (Orientation, orientation), + (IsRequiredForForm, is_required) } patterns! {