Eliminate the need for an explicit is_accesskit_active method, at least for now
This commit is contained in:
parent
49bbcf9b2e
commit
7763ee09dc
2 changed files with 71 additions and 77 deletions
|
@ -480,7 +480,7 @@ impl Context {
|
||||||
self.check_for_id_clash(id, rect, "widget");
|
self.check_for_id_clash(id, rect, "widget");
|
||||||
|
|
||||||
#[cfg(feature = "accesskit")]
|
#[cfg(feature = "accesskit")]
|
||||||
if self.is_accesskit_active() && sense.focusable {
|
if sense.focusable {
|
||||||
// Make sure anything that can receive focus has an AccessKit node.
|
// Make sure anything that can receive focus has an AccessKit node.
|
||||||
// TODO(mwcampbell): For nodes that are filled from widget info,
|
// TODO(mwcampbell): For nodes that are filled from widget info,
|
||||||
// some information is written to the node twice.
|
// some information is written to the node twice.
|
||||||
|
@ -1591,12 +1591,6 @@ impl Context {
|
||||||
.then(move || RwLockWriteGuard::map(ctx, |c| c.accesskit_node(id, parent_id)))
|
.then(move || RwLockWriteGuard::map(ctx, |c| c.accesskit_node(id, parent_id)))
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Returns whether AccessKit is active for the current frame.
|
|
||||||
#[cfg(feature = "accesskit")]
|
|
||||||
pub fn is_accesskit_active(&self) -> bool {
|
|
||||||
self.output().accesskit_update.is_some()
|
|
||||||
}
|
|
||||||
|
|
||||||
/// Enable generation of AccessKit tree updates in all future frames.
|
/// Enable generation of AccessKit tree updates in all future frames.
|
||||||
///
|
///
|
||||||
/// If it's practical for the egui integration to immediately run the egui
|
/// If it's practical for the egui integration to immediately run the egui
|
||||||
|
|
|
@ -659,13 +659,33 @@ impl<'t> TextEdit<'t> {
|
||||||
}
|
}
|
||||||
|
|
||||||
#[cfg(feature = "accesskit")]
|
#[cfg(feature = "accesskit")]
|
||||||
if ui.ctx().is_accesskit_active() {
|
if let Some(mut node) = ui.ctx().accesskit_node(response.id, None) {
|
||||||
use accesskit::{Role, TextDirection, TextPosition, TextSelection};
|
use accesskit::{Role, TextDirection, TextPosition, TextSelection};
|
||||||
|
|
||||||
let parent_id = response.id;
|
let parent_id = response.id;
|
||||||
|
|
||||||
|
if let Some(cursor_range) = &cursor_range {
|
||||||
|
let anchor = &cursor_range.secondary.rcursor;
|
||||||
|
let focus = &cursor_range.primary.rcursor;
|
||||||
|
node.text_selection = Some(TextSelection {
|
||||||
|
anchor: TextPosition {
|
||||||
|
node: parent_id.with(anchor.row).accesskit_id(),
|
||||||
|
character_index: anchor.column,
|
||||||
|
},
|
||||||
|
focus: TextPosition {
|
||||||
|
node: parent_id.with(focus.row).accesskit_id(),
|
||||||
|
character_index: focus.column,
|
||||||
|
},
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
node.default_action_verb = Some(accesskit::DefaultActionVerb::Focus);
|
||||||
|
|
||||||
|
drop(node);
|
||||||
|
|
||||||
for (i, row) in galley.rows.iter().enumerate() {
|
for (i, row) in galley.rows.iter().enumerate() {
|
||||||
let id = parent_id.with(i);
|
let id = parent_id.with(i);
|
||||||
if let Some(mut node) = ui.ctx().accesskit_node(id, Some(parent_id)) {
|
let mut node = ui.ctx().accesskit_node(id, Some(parent_id)).unwrap();
|
||||||
node.role = Role::InlineTextBox;
|
node.role = Role::InlineTextBox;
|
||||||
let rect = row.rect.translate(text_draw_pos.to_vec2());
|
let rect = row.rect.translate(text_draw_pos.to_vec2());
|
||||||
node.bounds = Some(accesskit::kurbo::Rect {
|
node.bounds = Some(accesskit::kurbo::Rect {
|
||||||
|
@ -720,26 +740,6 @@ impl<'t> TextEdit<'t> {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if let Some(mut node) = ui.ctx().accesskit_node(parent_id, None) {
|
|
||||||
if let Some(cursor_range) = &cursor_range {
|
|
||||||
let anchor = &cursor_range.secondary.rcursor;
|
|
||||||
let focus = &cursor_range.primary.rcursor;
|
|
||||||
node.text_selection = Some(TextSelection {
|
|
||||||
anchor: TextPosition {
|
|
||||||
node: parent_id.with(anchor.row).accesskit_id(),
|
|
||||||
character_index: anchor.column,
|
|
||||||
},
|
|
||||||
focus: TextPosition {
|
|
||||||
node: parent_id.with(focus.row).accesskit_id(),
|
|
||||||
character_index: focus.column,
|
|
||||||
},
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
node.default_action_verb = Some(accesskit::DefaultActionVerb::Focus);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
TextEditOutput {
|
TextEditOutput {
|
||||||
response,
|
response,
|
||||||
galley,
|
galley,
|
||||||
|
|
Loading…
Reference in a new issue