Skip to content

Commit fa15c84

Browse files
lukewarlowDataTriny
authored andcommitted
fix: expose more node data to UIA in aria_properties
1 parent 3d0d873 commit fa15c84

File tree

2 files changed

+86
-2
lines changed

2 files changed

+86
-2
lines changed

platforms/windows/src/node.rs

Lines changed: 78 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,8 @@
1111
#![allow(non_upper_case_globals)]
1212

1313
use accesskit::{
14-
Action, ActionData, ActionRequest, Live, NodeId, NodeIdContent, Orientation, Point, Role,
15-
Toggled,
14+
Action, ActionData, ActionRequest, AriaCurrent, HasPopup, Live, NodeId, NodeIdContent,
15+
Orientation, Point, Role, SortDirection, Toggled,
1616
};
1717
use accesskit_consumer::{FilterResult, Node, TreeState};
1818
use std::sync::{atomic::Ordering, Arc, Weak};
@@ -302,6 +302,11 @@ impl NodeWrapper<'_> {
302302
let mut result = WideString::default();
303303
let mut properties = AriaProperties::new(&mut result);
304304

305+
// TODO: Atomic, and busy flags should include false when explicitly set to that
306+
if self.0.is_live_atomic() {
307+
properties.write_bool_property("atomic", true).unwrap();
308+
}
309+
305310
if let Some(label) = self.0.braille_label() {
306311
properties.write_property("braillelabel", label).unwrap();
307312
}
@@ -312,6 +317,77 @@ impl NodeWrapper<'_> {
312317
.unwrap();
313318
}
314319

320+
if self.0.is_busy() {
321+
properties.write_bool_property("busy", true).unwrap();
322+
}
323+
324+
if let Some(colindextext) = self.0.column_index_text() {
325+
properties
326+
.write_property("colindextext", colindextext)
327+
.unwrap();
328+
}
329+
330+
if let Some(current) = self.0.aria_current() {
331+
if current != AriaCurrent::False {
332+
properties
333+
.write_property(
334+
"current",
335+
match current {
336+
AriaCurrent::True => "true",
337+
AriaCurrent::Page => "page",
338+
AriaCurrent::Step => "step",
339+
AriaCurrent::Location => "location",
340+
AriaCurrent::Date => "date",
341+
AriaCurrent::Time => "time",
342+
AriaCurrent::False => unreachable!(),
343+
},
344+
)
345+
.unwrap();
346+
}
347+
}
348+
349+
if let Some(has_popup) = self.0.has_popup() {
350+
properties
351+
.write_property(
352+
"haspopup",
353+
match has_popup {
354+
HasPopup::Menu => "menu",
355+
HasPopup::Listbox => "listbox",
356+
HasPopup::Tree => "tree",
357+
HasPopup::Grid => "grid",
358+
HasPopup::Dialog => "dialog",
359+
},
360+
)
361+
.unwrap();
362+
}
363+
364+
if let Some(level) = self.0.level() {
365+
properties.write_usize_property("level", level).unwrap();
366+
}
367+
368+
if self.0.is_multiline() {
369+
properties.write_bool_property("multiline", true).unwrap();
370+
}
371+
372+
if let Some(rowindextext) = self.0.row_index_text() {
373+
properties
374+
.write_property("rowindextext", rowindextext)
375+
.unwrap();
376+
}
377+
378+
if let Some(sort_direction) = self.0.sort_direction() {
379+
properties
380+
.write_property(
381+
"sort",
382+
match sort_direction {
383+
SortDirection::Ascending => "ascending",
384+
SortDirection::Descending => "descending",
385+
SortDirection::Other => "other",
386+
},
387+
)
388+
.unwrap();
389+
}
390+
315391
if properties.has_properties() {
316392
Some(result)
317393
} else {

platforms/windows/src/util.rs

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -332,6 +332,14 @@ impl<W: Write> AriaProperties<W> {
332332
Ok(())
333333
}
334334

335+
pub(crate) fn write_bool_property(&mut self, name: &str, value: bool) -> fmt::Result {
336+
self.write_property(name, if value { "true" } else { "false" })
337+
}
338+
339+
pub(crate) fn write_usize_property(&mut self, name: &str, value: usize) -> fmt::Result {
340+
self.write_property(name, &value.to_string())
341+
}
342+
335343
pub(crate) fn has_properties(&self) -> bool {
336344
self.need_separator
337345
}

0 commit comments

Comments
 (0)