Tell AccessKit that the default action for a text edit (equivalent to a click) is to set the focus. This matters to some platform adapters.

This commit is contained in:
Matt Campbell 2022-11-29 12:16:11 -06:00
parent a472d147d6
commit 9e10822172
2 changed files with 5 additions and 2 deletions

View file

@ -552,7 +552,7 @@ impl Response {
if self.sense.focusable {
node.focusable = true;
}
if self.sense.click {
if self.sense.click && node.default_action_verb.is_none() {
node.default_action_verb = Some(accesskit::DefaultActionVerb::Click);
}
}

View file

@ -719,8 +719,9 @@ impl<'t> TextEdit<'t> {
node.word_lengths = word_lengths.into();
}
let mut node = ui.ctx().accesskit_node(parent_id, None);
if let Some(cursor_range) = &cursor_range {
let mut node = ui.ctx().accesskit_node(parent_id, None);
let anchor = &cursor_range.secondary.rcursor;
let focus = &cursor_range.primary.rcursor;
node.text_selection = Some(TextSelection {
@ -734,6 +735,8 @@ impl<'t> TextEdit<'t> {
},
});
}
node.default_action_verb = Some(accesskit::DefaultActionVerb::Focus);
}
TextEditOutput {