From 599d147cf6f108273c7fabde7dbf39e86a8804dc Mon Sep 17 00:00:00 2001 From: Matt Campbell Date: Tue, 29 Nov 2022 13:13:48 -0600 Subject: [PATCH] Support the AccessKit SetValue for DragValue; this is the only way for a Windows AT to programmatically adjust the value --- crates/egui/src/widgets/drag_value.rs | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/crates/egui/src/widgets/drag_value.rs b/crates/egui/src/widgets/drag_value.rs index e0227ccb..fe6f2b36 100644 --- a/crates/egui/src/widgets/drag_value.rs +++ b/crates/egui/src/widgets/drag_value.rs @@ -417,6 +417,16 @@ impl<'a> Widget for DragValue<'a> { change }; + #[cfg(feature = "accesskit")] + { + use accesskit::{Action, ActionData}; + for request in ui.input().accesskit_action_requests(id, Action::SetValue) { + if let Some(ActionData::NumericValue(new_value)) = request.data { + value = new_value; + } + } + } + if change != 0.0 { value += speed * change; value = emath::round_to_decimals(value, auto_decimals); @@ -543,6 +553,8 @@ impl<'a> Widget for DragValue<'a> { if clamp_range.end().is_finite() { node.max_numeric_value = Some(*clamp_range.end()); } + node.numeric_value_step = Some(speed); + node.actions |= Action::SetValue; if value < *clamp_range.end() { node.actions |= Action::Increment; }