Skip to content

Commit

Permalink
feat: Expose the is_required property (#497)
Browse files Browse the repository at this point in the history
  • Loading branch information
DataTriny authored Dec 15, 2024
1 parent a86901d commit 46ed99b
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 1 deletion.
4 changes: 4 additions & 0 deletions consumer/src/node.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down
3 changes: 3 additions & 0 deletions platforms/atspi-common/src/node.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
7 changes: 7 additions & 0 deletions platforms/macos/src/node.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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| {
Expand Down Expand Up @@ -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)
Expand Down
7 changes: 6 additions & 1 deletion platforms/windows/src/node.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -885,7 +889,8 @@ properties! {
(LiveSetting, live_setting),
(AutomationId, automation_id),
(ClassName, class_name),
(Orientation, orientation)
(Orientation, orientation),
(IsRequiredForForm, is_required)
}

patterns! {
Expand Down

0 comments on commit 46ed99b

Please sign in to comment.