DragValue: only show extra decimal with shift down if currently dragged

This commit is contained in:
Emil Ernerfeldt 2021-04-21 22:14:30 +02:00
parent d2b669e1cd
commit a59c8ac2c3
2 changed files with 6 additions and 1 deletions

View file

@ -462,6 +462,10 @@ impl Ui {
Id::new(self.next_auto_id) Id::new(self.next_auto_id)
} }
pub(crate) fn next_auto_id(&self) -> Id {
Id::new(self.next_auto_id.wrapping_add(1))
}
pub(crate) fn auto_id_with<IdSource>(&self, id_source: IdSource) -> Id pub(crate) fn auto_id_with<IdSource>(&self, id_source: IdSource) -> Id
where where
IdSource: Hash + std::fmt::Debug, IdSource: Hash + std::fmt::Debug,

View file

@ -217,7 +217,8 @@ impl<'a> Widget for DragValue<'a> {
max_decimals, max_decimals,
} = self; } = self;
let is_slow_speed = ui.input().modifiers.shift_only(); let is_slow_speed =
ui.input().modifiers.shift_only() && ui.memory().is_being_dragged(ui.next_auto_id());
let value = get(&mut get_set_value); let value = get(&mut get_set_value);
let value = clamp_to_range(value, clamp_range.clone()); let value = clamp_to_range(value, clamp_range.clone());