From 270173eb367d43e4a14fdcf563655aad4c8ce8d0 Mon Sep 17 00:00:00 2001 From: Arnold Loubriat Date: Sat, 24 Aug 2024 11:00:04 +0200 Subject: [PATCH] Remove the `accesskit` feature on egui --- crates/eframe/Cargo.toml | 2 +- crates/eframe/src/web/app_runner.rs | 3 +- crates/egui-winit/Cargo.toml | 2 +- crates/egui-winit/src/lib.rs | 5 +- crates/egui/Cargo.toml | 9 +--- crates/egui/src/context.rs | 54 +++++++------------ crates/egui/src/data/input.rs | 1 - crates/egui/src/data/output.rs | 11 ++-- crates/egui/src/frame_state.rs | 9 +--- crates/egui/src/id.rs | 1 - crates/egui/src/input_state.rs | 3 -- crates/egui/src/lib.rs | 2 - crates/egui/src/memory.rs | 34 +++++------- crates/egui/src/response.rs | 16 ++---- .../egui/src/text_selection/cursor_range.rs | 2 - .../text_selection/label_text_selection.rs | 1 - crates/egui/src/text_selection/mod.rs | 1 - crates/egui/src/widgets/drag_value.rs | 28 ++++------ crates/egui/src/widgets/slider.rs | 32 +++++------ crates/egui/src/widgets/text_edit/builder.rs | 33 ++++++------ 20 files changed, 83 insertions(+), 166 deletions(-) diff --git a/crates/eframe/Cargo.toml b/crates/eframe/Cargo.toml index 0b18845c34a..70aadc89600 100644 --- a/crates/eframe/Cargo.toml +++ b/crates/eframe/Cargo.toml @@ -42,7 +42,7 @@ default = [ ] ## Enable platform accessibility API implementations through [AccessKit](https://accesskit.dev/). -accesskit = ["egui/accesskit", "egui-winit/accesskit"] +accesskit = ["egui-winit/accesskit"] # Allow crates to choose an android-activity backend via Winit # - It's important that most applications should not have to depend on android-activity directly, and can diff --git a/crates/eframe/src/web/app_runner.rs b/crates/eframe/src/web/app_runner.rs index 216fa16ecce..ced3ff8f45a 100644 --- a/crates/eframe/src/web/app_runner.rs +++ b/crates/eframe/src/web/app_runner.rs @@ -267,8 +267,7 @@ impl AppRunner { events: _, // already handled mutable_text_under_cursor: _, // TODO(#4569): https://github.com/emilk/egui/issues/4569 ime, - #[cfg(feature = "accesskit")] - accesskit_update: _, // not currently implemented + .. } = platform_output; super::set_cursor_icon(cursor_icon); diff --git a/crates/egui-winit/Cargo.toml b/crates/egui-winit/Cargo.toml index 4060442f6dc..47d2264108b 100644 --- a/crates/egui-winit/Cargo.toml +++ b/crates/egui-winit/Cargo.toml @@ -24,7 +24,7 @@ all-features = true default = ["clipboard", "links", "wayland", "winit/default", "x11"] ## Enable platform accessibility API implementations through [AccessKit](https://accesskit.dev/). -accesskit = ["accesskit_winit", "egui/accesskit"] +accesskit = ["accesskit_winit"] # Allow crates to choose an android-activity backend via Winit # - It's important that most applications should not have to depend on android-activity directly, and can diff --git a/crates/egui-winit/src/lib.rs b/crates/egui-winit/src/lib.rs index 10d79a3af03..183a8d465f0 100644 --- a/crates/egui-winit/src/lib.rs +++ b/crates/egui-winit/src/lib.rs @@ -821,8 +821,7 @@ impl State { events: _, // handled elsewhere mutable_text_under_cursor: _, // only used in eframe web ime, - #[cfg(feature = "accesskit")] - accesskit_update, + .. } = platform_output; self.set_cursor_icon(window, cursor_icon); @@ -867,7 +866,7 @@ impl State { #[cfg(feature = "accesskit")] if let Some(accesskit) = self.accesskit.as_mut() { - if let Some(update) = accesskit_update { + if let Some(update) = platform_output.accesskit_update { crate::profile_scope!("accesskit"); accesskit.update_if_active(|| update); } diff --git a/crates/egui/Cargo.toml b/crates/egui/Cargo.toml index a920df2bf46..e67ee80dadf 100644 --- a/crates/egui/Cargo.toml +++ b/crates/egui/Cargo.toml @@ -25,10 +25,6 @@ all-features = true [features] default = ["default_fonts"] -## Exposes detailed accessibility implementation required by platform -## accessibility APIs. Also requires support in the egui integration. -accesskit = ["dep:accesskit"] - ## [`bytemuck`](https://docs.rs/bytemuck) enables you to cast [`epaint::Vertex`], [`emath::Vec2`] etc to `&[u8]`. bytemuck = ["epaint/bytemuck"] @@ -72,7 +68,7 @@ puffin = ["dep:puffin", "epaint/puffin"] rayon = ["epaint/rayon"] ## Allow serialization using [`serde`](https://docs.rs/serde). -serde = ["dep:serde", "epaint/serde", "accesskit?/serde"] +serde = ["dep:serde", "epaint/serde", "accesskit/serde"] ## Change Vertex layout to be compatible with unity unity = ["epaint/unity"] @@ -82,12 +78,11 @@ unity = ["epaint/unity"] emath = { workspace = true, default-features = false } epaint = { workspace = true, default-features = false } +accesskit = "0.16" ahash.workspace = true nohash-hasher.workspace = true #! ### Optional dependencies -accesskit = { version = "0.16", optional = true } - backtrace = { workspace = true, optional = true } ## Enable this when generating docs. diff --git a/crates/egui/src/context.rs b/crates/egui/src/context.rs index d1a05db4bc2..56faf5f9fea 100644 --- a/crates/egui/src/context.rs +++ b/crates/egui/src/context.rs @@ -394,7 +394,6 @@ struct ContextImpl { embed_viewports: bool, - #[cfg(feature = "accesskit")] is_accesskit_enabled: bool, loaders: Arc, @@ -505,7 +504,6 @@ impl ContextImpl { }, ); - #[cfg(feature = "accesskit")] if self.is_accesskit_enabled { crate::profile_scope!("accesskit"); use crate::frame_state::AccessKitFrameState; @@ -573,7 +571,6 @@ impl ContextImpl { } } - #[cfg(feature = "accesskit")] fn accesskit_node_builder(&mut self, id: Id) -> &mut accesskit::NodeBuilder { let state = self.viewport().this_frame.accesskit_state.as_mut().unwrap(); let builders = &mut state.node_builders; @@ -1061,7 +1058,6 @@ impl Context { #[allow(clippy::let_and_return)] let res = self.get_response(w); - #[cfg(feature = "accesskit")] if w.sense.focusable { // Make sure anything that can receive focus has an AccessKit node. // TODO(mwcampbell): For nodes that are filled from widget info, @@ -1150,7 +1146,6 @@ impl Context { res.fake_primary_click = true; } - #[cfg(feature = "accesskit")] if enabled && sense.click && input.has_accesskit_action_request(id, accesskit::Action::Default) @@ -2001,32 +1996,28 @@ impl ContextImpl { // Inform the backend of all textures that have been updated (including font atlas). let textures_delta = self.tex_manager.0.write().take_delta(); - #[cfg_attr(not(feature = "accesskit"), allow(unused_mut))] let mut platform_output: PlatformOutput = std::mem::take(&mut viewport.output); - #[cfg(feature = "accesskit")] - { - crate::profile_scope!("accesskit"); - let state = viewport.this_frame.accesskit_state.take(); - if let Some(state) = state { - let root_id = crate::accesskit_root_id().accesskit_id(); - let nodes = { - state - .node_builders - .into_iter() - .map(|(id, builder)| (id.accesskit_id(), builder.build())) - .collect() - }; - let focus_id = self - .memory - .focused() - .map_or(root_id, |id| id.accesskit_id()); - platform_output.accesskit_update = Some(accesskit::TreeUpdate { - nodes, - tree: Some(accesskit::Tree::new(root_id)), - focus: focus_id, - }); - } + crate::profile_scope!("accesskit"); + let state = viewport.this_frame.accesskit_state.take(); + if let Some(state) = state { + let root_id = crate::accesskit_root_id().accesskit_id(); + let nodes = { + state + .node_builders + .into_iter() + .map(|(id, builder)| (id.accesskit_id(), builder.build())) + .collect() + }; + let focus_id = self + .memory + .focused() + .map_or(root_id, |id| id.accesskit_id()); + platform_output.accesskit_update = Some(accesskit::TreeUpdate { + nodes, + tree: Some(accesskit::Tree::new(root_id)), + focus: focus_id, + }); } let shapes = viewport @@ -2859,7 +2850,6 @@ impl Context { #[inline] pub fn with_accessibility_parent(&self, _id: Id, f: impl FnOnce()) { // TODO(emilk): this isn't thread-safe - another thread can call this function between the push/pop calls - #[cfg(feature = "accesskit")] self.frame_state_mut(|fs| { if let Some(state) = fs.accesskit_state.as_mut() { state.parent_stack.push(_id); @@ -2868,7 +2858,6 @@ impl Context { f(); - #[cfg(feature = "accesskit")] self.frame_state_mut(|fs| { if let Some(state) = fs.accesskit_state.as_mut() { assert_eq!(state.parent_stack.pop(), Some(_id)); @@ -2885,7 +2874,6 @@ impl Context { /// /// Returns `None` if acesskit is off. // TODO(emilk): consider making both read-only and read-write versions - #[cfg(feature = "accesskit")] pub fn accesskit_node_builder( &self, id: Id, @@ -2902,13 +2890,11 @@ impl Context { } /// Enable generation of AccessKit tree updates in all future frames. - #[cfg(feature = "accesskit")] pub fn enable_accesskit(&self) { self.write(|ctx| ctx.is_accesskit_enabled = true); } /// Disable generation of AccessKit tree updates in all future frames. - #[cfg(feature = "accesskit")] pub fn disable_accesskit(&self) { self.write(|ctx| ctx.is_accesskit_enabled = false); } diff --git a/crates/egui/src/data/input.rs b/crates/egui/src/data/input.rs index 3bc88037426..cdcf8eb265d 100644 --- a/crates/egui/src/data/input.rs +++ b/crates/egui/src/data/input.rs @@ -499,7 +499,6 @@ pub enum Event { WindowFocused(bool), /// An assistive technology (e.g. screen reader) requested an action. - #[cfg(feature = "accesskit")] AccessKitActionRequest(accesskit::ActionRequest), /// The reply of a screenshot requested with [`crate::ViewportCommand::Screenshot`]. diff --git a/crates/egui/src/data/output.rs b/crates/egui/src/data/output.rs index 58df5da230a..1dc2950b10f 100644 --- a/crates/egui/src/data/output.rs +++ b/crates/egui/src/data/output.rs @@ -121,7 +121,6 @@ pub struct PlatformOutput { /// The difference in the widget tree since last frame. /// /// NOTE: this needs to be per-viewport. - #[cfg(feature = "accesskit")] pub accesskit_update: Option, } @@ -153,7 +152,6 @@ impl PlatformOutput { mut events, mutable_text_under_cursor, ime, - #[cfg(feature = "accesskit")] accesskit_update, } = newer; @@ -168,12 +166,9 @@ impl PlatformOutput { self.mutable_text_under_cursor = mutable_text_under_cursor; self.ime = ime.or(self.ime); - #[cfg(feature = "accesskit")] - { - // egui produces a complete AccessKit tree for each frame, - // so overwrite rather than appending. - self.accesskit_update = accesskit_update; - } + // egui produces a complete AccessKit tree for each frame, + // so overwrite rather than appending. + self.accesskit_update = accesskit_update; } /// Take everything ephemeral (everything except `cursor_icon` currently) diff --git a/crates/egui/src/frame_state.rs b/crates/egui/src/frame_state.rs index 70c558fc498..1ecb37dd7ee 100644 --- a/crates/egui/src/frame_state.rs +++ b/crates/egui/src/frame_state.rs @@ -64,7 +64,6 @@ impl ScrollTarget { } } -#[cfg(feature = "accesskit")] #[derive(Clone)] pub struct AccessKitFrameState { pub node_builders: IdMap, @@ -209,7 +208,6 @@ pub struct FrameState { /// as when swiping down on a touch-screen or track-pad with natural scrolling. pub scroll_delta: (Vec2, style::ScrollAnimation), - #[cfg(feature = "accesskit")] pub accesskit_state: Option, /// Highlight these widgets the next frame. @@ -231,7 +229,6 @@ impl Default for FrameState { used_by_panels: Rect::NAN, scroll_target: [None, None], scroll_delta: (Vec2::default(), style::ScrollAnimation::none()), - #[cfg(feature = "accesskit")] accesskit_state: None, highlight_next_frame: Default::default(), @@ -254,7 +251,6 @@ impl FrameState { used_by_panels, scroll_target, scroll_delta, - #[cfg(feature = "accesskit")] accesskit_state, highlight_next_frame, @@ -277,10 +273,7 @@ impl FrameState { *debug_rect = None; } - #[cfg(feature = "accesskit")] - { - *accesskit_state = None; - } + *accesskit_state = None; highlight_next_frame.clear(); } diff --git a/crates/egui/src/id.rs b/crates/egui/src/id.rs index c5047c26613..d25347a81e0 100644 --- a/crates/egui/src/id.rs +++ b/crates/egui/src/id.rs @@ -77,7 +77,6 @@ impl Id { self.0.get() } - #[cfg(feature = "accesskit")] pub(crate) fn accesskit_id(&self) -> accesskit::NodeId { self.value().into() } diff --git a/crates/egui/src/input_state.rs b/crates/egui/src/input_state.rs index 5749e16825f..f1f3961515f 100644 --- a/crates/egui/src/input_state.rs +++ b/crates/egui/src/input_state.rs @@ -623,7 +623,6 @@ impl InputState { } } - #[cfg(feature = "accesskit")] pub fn accesskit_action_requests( &self, id: crate::Id, @@ -640,12 +639,10 @@ impl InputState { }) } - #[cfg(feature = "accesskit")] pub fn has_accesskit_action_request(&self, id: crate::Id, action: accesskit::Action) -> bool { self.accesskit_action_requests(id, action).next().is_some() } - #[cfg(feature = "accesskit")] pub fn num_accesskit_action_requests(&self, id: crate::Id, action: accesskit::Action) -> usize { self.accesskit_action_requests(id, action).count() } diff --git a/crates/egui/src/lib.rs b/crates/egui/src/lib.rs index 92436215f2f..e0041267587 100644 --- a/crates/egui/src/lib.rs +++ b/crates/egui/src/lib.rs @@ -411,7 +411,6 @@ pub mod widgets; #[cfg(debug_assertions)] mod callstack; -#[cfg(feature = "accesskit")] pub use accesskit; pub use ahash; @@ -659,7 +658,6 @@ pub fn __run_test_ui(mut add_contents: impl FnMut(&mut Ui)) { }); } -#[cfg(feature = "accesskit")] pub fn accesskit_root_id() -> Id { Id::new("accesskit_root") } diff --git a/crates/egui/src/memory.rs b/crates/egui/src/memory.rs index 86aa3526799..9c615e3c1bc 100644 --- a/crates/egui/src/memory.rs +++ b/crates/egui/src/memory.rs @@ -440,7 +440,6 @@ pub(crate) struct Focus { /// Give focus to this widget next frame id_next_frame: Option, - #[cfg(feature = "accesskit")] id_requested_by_accesskit: Option, /// If set, the next widget that is interested in focus will automatically get it. @@ -493,10 +492,7 @@ impl Focus { } let event_filter = self.focused_widget.map(|w| w.filter).unwrap_or_default(); - #[cfg(feature = "accesskit")] - { - self.id_requested_by_accesskit = None; - } + self.id_requested_by_accesskit = None; self.focus_direction = FocusDirection::None; @@ -533,16 +529,13 @@ impl Focus { } } - #[cfg(feature = "accesskit")] + if let crate::Event::AccessKitActionRequest(accesskit::ActionRequest { + action: accesskit::Action::Focus, + target, + data: None, + }) = event { - if let crate::Event::AccessKitActionRequest(accesskit::ActionRequest { - action: accesskit::Action::Focus, - target, - data: None, - }) = event - { - self.id_requested_by_accesskit = Some(*target); - } + self.id_requested_by_accesskit = Some(*target); } } } @@ -570,14 +563,11 @@ impl Focus { } fn interested_in_focus(&mut self, id: Id) { - #[cfg(feature = "accesskit")] - { - if self.id_requested_by_accesskit == Some(id.accesskit_id()) { - self.focused_widget = Some(FocusWidget::new(id)); - self.id_requested_by_accesskit = None; - self.give_to_next = false; - self.reset_focus(); - } + if self.id_requested_by_accesskit == Some(id.accesskit_id()) { + self.focused_widget = Some(FocusWidget::new(id)); + self.id_requested_by_accesskit = None; + self.give_to_next = false; + self.reset_focus(); } // The rect is updated at the end of the frame. diff --git a/crates/egui/src/response.rs b/crates/egui/src/response.rs index d6a9a8a0c7f..11472b2829a 100644 --- a/crates/egui/src/response.rs +++ b/crates/egui/src/response.rs @@ -3,7 +3,7 @@ use std::{any::Any, sync::Arc}; use crate::{ emath::{Align, Pos2, Rect, Vec2}, frame_state, menu, AreaState, Context, CursorIcon, Id, LayerId, Order, PointerButton, Sense, - Ui, WidgetRect, WidgetText, + Ui, WidgetInfo, WidgetRect, WidgetText, WidgetType, }; // ---------------------------------------------------------------------------- @@ -913,7 +913,7 @@ impl Response { /// For accessibility. /// /// Call after interacting and potential calls to [`Self::mark_changed`]. - pub fn widget_info(&self, make_info: impl Fn() -> crate::WidgetInfo) { + pub fn widget_info(&self, make_info: impl Fn() -> WidgetInfo) { use crate::output::OutputEvent; let event = if self.clicked() { @@ -933,7 +933,6 @@ impl Response { if let Some(event) = event { self.output_event(event); } else { - #[cfg(feature = "accesskit")] self.ctx.accesskit_node_builder(self.id, |builder| { self.fill_accesskit_node_from_widget_info(builder, make_info()); }); @@ -943,7 +942,6 @@ impl Response { } pub fn output_event(&self, event: crate::output::OutputEvent) { - #[cfg(feature = "accesskit")] self.ctx.accesskit_node_builder(self.id, |builder| { self.fill_accesskit_node_from_widget_info(builder, event.widget_info().clone()); }); @@ -954,7 +952,6 @@ impl Response { self.ctx.output_mut(|o| o.events.push(event)); } - #[cfg(feature = "accesskit")] pub(crate) fn fill_accesskit_node_common(&self, builder: &mut accesskit::NodeBuilder) { if !self.enabled { builder.set_disabled(); @@ -973,13 +970,11 @@ impl Response { } } - #[cfg(feature = "accesskit")] fn fill_accesskit_node_from_widget_info( &self, builder: &mut accesskit::NodeBuilder, - info: crate::WidgetInfo, + info: WidgetInfo, ) { - use crate::WidgetType; use accesskit::{Role, Toggled}; self.fill_accesskit_node_common(builder); @@ -1038,14 +1033,9 @@ impl Response { /// # }); /// ``` pub fn labelled_by(self, id: Id) -> Self { - #[cfg(feature = "accesskit")] self.ctx.accesskit_node_builder(self.id, |builder| { builder.push_labelled_by(id.accesskit_id()); }); - #[cfg(not(feature = "accesskit"))] - { - let _ = id; - } self } diff --git a/crates/egui/src/text_selection/cursor_range.rs b/crates/egui/src/text_selection/cursor_range.rs index 7a6199834fe..f924564c511 100644 --- a/crates/egui/src/text_selection/cursor_range.rs +++ b/crates/egui/src/text_selection/cursor_range.rs @@ -180,7 +180,6 @@ impl CursorRange { .. } => self.on_key_press(os, galley, modifiers, *key), - #[cfg(feature = "accesskit")] Event::AccessKitActionRequest(accesskit::ActionRequest { action: accesskit::Action::SetTextSelection, target, @@ -274,7 +273,6 @@ pub struct PCursorRange { // ---------------------------------------------------------------------------- -#[cfg(feature = "accesskit")] fn ccursor_from_accesskit_text_position( id: Id, galley: &Galley, diff --git a/crates/egui/src/text_selection/label_text_selection.rs b/crates/egui/src/text_selection/label_text_selection.rs index c80b72023d9..2b59d68c29a 100644 --- a/crates/egui/src/text_selection/label_text_selection.rs +++ b/crates/egui/src/text_selection/label_text_selection.rs @@ -33,7 +33,6 @@ fn paint_selection( ); } - #[cfg(feature = "accesskit")] super::accesskit_text::update_accesskit_for_text_widget( ui.ctx(), _response.id, diff --git a/crates/egui/src/text_selection/mod.rs b/crates/egui/src/text_selection/mod.rs index 5be95eb53bf..afd8a0fd660 100644 --- a/crates/egui/src/text_selection/mod.rs +++ b/crates/egui/src/text_selection/mod.rs @@ -1,6 +1,5 @@ //! Helpers regarding text selection for labels and text edit. -#[cfg(feature = "accesskit")] pub mod accesskit_text; mod cursor_range; diff --git a/crates/egui/src/widgets/drag_value.rs b/crates/egui/src/widgets/drag_value.rs index 26bbc38cb79..fcc375ee467 100644 --- a/crates/egui/src/widgets/drag_value.rs +++ b/crates/egui/src/widgets/drag_value.rs @@ -2,6 +2,8 @@ use std::{cmp::Ordering, ops::RangeInclusive}; +use accesskit::{Action, ActionData}; + use crate::*; // ---------------------------------------------------------------------------- @@ -445,27 +447,19 @@ impl<'a> Widget for DragValue<'a> { - input.count_and_consume_key(Modifiers::NONE, Key::ArrowDown) as f64; } - #[cfg(feature = "accesskit")] - { - use accesskit::Action; - change += input.num_accesskit_action_requests(id, Action::Increment) as f64 - - input.num_accesskit_action_requests(id, Action::Decrement) as f64; - } + change += input.num_accesskit_action_requests(id, Action::Increment) as f64 + - input.num_accesskit_action_requests(id, Action::Decrement) as f64; change }); - #[cfg(feature = "accesskit")] - { - use accesskit::{Action, ActionData}; - ui.input(|input| { - for request in input.accesskit_action_requests(id, Action::SetValue) { - if let Some(ActionData::NumericValue(new_value)) = request.data { - value = new_value; - } + ui.input(|input| { + for request in input.accesskit_action_requests(id, Action::SetValue) { + if let Some(ActionData::NumericValue(new_value)) = request.data { + value = new_value; } - }); - } + } + }); if clamp_to_range { value = clamp_value_to_range(value, range.clone()); @@ -623,9 +617,7 @@ impl<'a> Widget for DragValue<'a> { response.widget_info(|| WidgetInfo::drag_value(ui.is_enabled(), value)); - #[cfg(feature = "accesskit")] ui.ctx().accesskit_node_builder(response.id, |builder| { - use accesskit::Action; // If either end of the range is unbounded, it's better // to leave the corresponding AccessKit field set to None, // to allow for platform-specific default behavior. diff --git a/crates/egui/src/widgets/slider.rs b/crates/egui/src/widgets/slider.rs index 84e47aeef3e..87c69d30526 100644 --- a/crates/egui/src/widgets/slider.rs +++ b/crates/egui/src/widgets/slider.rs @@ -2,6 +2,8 @@ use std::ops::RangeInclusive; +use accesskit::{Action, ActionData}; + use crate::{style::HandleShape, *}; // ---------------------------------------------------------------------------- @@ -627,14 +629,10 @@ impl<'a> Slider<'a> { }); } - #[cfg(feature = "accesskit")] - { - use accesskit::Action; - ui.input(|input| { - decrement += input.num_accesskit_action_requests(response.id, Action::Decrement); - increment += input.num_accesskit_action_requests(response.id, Action::Increment); - }); - } + ui.input(|input| { + decrement += input.num_accesskit_action_requests(response.id, Action::Decrement); + increment += input.num_accesskit_action_requests(response.id, Action::Increment); + }); let kb_step = increment as f32 - decrement as f32; @@ -657,17 +655,13 @@ impl<'a> Slider<'a> { self.set_value(new_value); } - #[cfg(feature = "accesskit")] - { - use accesskit::{Action, ActionData}; - ui.input(|input| { - for request in input.accesskit_action_requests(response.id, Action::SetValue) { - if let Some(ActionData::NumericValue(new_value)) = request.data { - self.set_value(new_value); - } + ui.input(|input| { + for request in input.accesskit_action_requests(response.id, Action::SetValue) { + if let Some(ActionData::NumericValue(new_value)) = request.data { + self.set_value(new_value); } - }); - } + } + }); // Paint it: if ui.is_rect_visible(response.rect) { @@ -855,9 +849,7 @@ impl<'a> Slider<'a> { response.changed = value != old_value; response.widget_info(|| WidgetInfo::slider(ui.is_enabled(), value, self.text.text())); - #[cfg(feature = "accesskit")] ui.ctx().accesskit_node_builder(response.id, |builder| { - use accesskit::Action; builder.set_min_numeric_value(*self.range.start()); builder.set_max_numeric_value(*self.range.end()); if let Some(step) = self.step { diff --git a/crates/egui/src/widgets/text_edit/builder.rs b/crates/egui/src/widgets/text_edit/builder.rs index 86d281256b7..2ee3c6e6e09 100644 --- a/crates/egui/src/widgets/text_edit/builder.rs +++ b/crates/egui/src/widgets/text_edit/builder.rs @@ -776,25 +776,22 @@ impl<'t> TextEdit<'t> { }); } - #[cfg(feature = "accesskit")] - { - let role = if password { - accesskit::Role::PasswordInput - } else if multiline { - accesskit::Role::MultilineTextInput - } else { - accesskit::Role::TextInput - }; + let role = if password { + accesskit::Role::PasswordInput + } else if multiline { + accesskit::Role::MultilineTextInput + } else { + accesskit::Role::TextInput + }; - crate::text_selection::accesskit_text::update_accesskit_for_text_widget( - ui.ctx(), - id, - cursor_range, - role, - galley_pos, - &galley, - ); - } + crate::text_selection::accesskit_text::update_accesskit_for_text_widget( + ui.ctx(), + id, + cursor_range, + role, + galley_pos, + &galley, + ); TextEditOutput { response,