Skip to content

Commit

Permalink
Fix accessibility misses
Browse files Browse the repository at this point in the history
  • Loading branch information
DJMcNab committed Nov 28, 2024
1 parent 13e913d commit b6bedd7
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 7 deletions.
9 changes: 5 additions & 4 deletions masonry/src/widget/label.rs
Original file line number Diff line number Diff line change
Expand Up @@ -413,15 +413,16 @@ impl Widget for Label {
Role::Label
}

fn accessibility(&mut self, _ctx: &mut AccessCtx, node: &mut Node) {
fn accessibility(&mut self, ctx: &mut AccessCtx, node: &mut Node) {
let window_origin = ctx.window_origin();
self.accessibility.build_nodes(
self.text.as_ref(),
&self.text_layout,
_ctx.tree_update,
ctx.tree_update,
node,
|| NodeId::from(WidgetId::next()),
LABEL_X_PADDING,
0.0,
(window_origin.x + LABEL_X_PADDING) * ctx.scale_factor,
window_origin.y * ctx.scale_factor,
);
}

Expand Down
13 changes: 10 additions & 3 deletions masonry/src/widget/text_area.rs
Original file line number Diff line number Diff line change
Expand Up @@ -835,15 +835,22 @@ impl<const EDITABLE: bool> Widget for TextArea<EDITABLE> {
}

fn accessibility(&mut self, ctx: &mut AccessCtx, node: &mut Node) {
if !EDITABLE {
node.set_read_only();
}
let (fctx, lctx) = ctx.text_contexts();
let is_rtl = self.editor.layout(fctx, lctx).is_rtl();
let (x_offset, y_offset) = (self.padding.get_left(is_rtl), self.padding.top);
let origin = ctx.window_origin();
let (x_offset, y_offset) = (
origin.x + self.padding.get_left(is_rtl),
origin.y + self.padding.top,
);
self.editor.accessibility(
ctx.tree_update,
node,
|| NodeId::from(WidgetId::next()),
x_offset,
y_offset,
ctx.scale_factor * x_offset,
ctx.scale_factor * y_offset,
);
}

Expand Down

0 comments on commit b6bedd7

Please sign in to comment.