1
0
mirror of https://github.com/emilk/egui.git synced 2026-08-30 21:30:03 -04:00

Fix vertical slider up/down keys and add a line in the changelog

Follow-up to https://github.com/emilk/egui/pull/875
This commit is contained in:
Emil Ernerfeldt
2021-11-13 12:30:13 +01:00
parent 491739b580
commit 4d4c75c6f1
3 changed files with 17 additions and 20 deletions

View File

@@ -315,8 +315,15 @@ impl<'a> Slider<'a> {
response.widget_info(|| WidgetInfo::slider(value, &self.text));
if response.has_focus() {
let increment = ui.input().num_presses(self.key_increment());
let decrement = ui.input().num_presses(self.key_decrement());
let (dec_key, inc_key) = match self.orientation {
SliderOrientation::Horizontal => (Key::ArrowLeft, Key::ArrowRight),
// Note that this is for moving the slider position,
// so up = decrement y coordinate:
SliderOrientation::Vertical => (Key::ArrowUp, Key::ArrowDown),
};
let decrement = ui.input().num_presses(dec_key);
let increment = ui.input().num_presses(inc_key);
let kb_step = increment as f32 - decrement as f32;
if kb_step != 0.0 {
@@ -394,20 +401,6 @@ impl<'a> Slider<'a> {
}
}
fn key_increment(&self) -> Key {
match self.orientation {
SliderOrientation::Horizontal => Key::ArrowRight,
SliderOrientation::Vertical => Key::ArrowUp,
}
}
fn key_decrement(&self) -> Key {
match self.orientation {
SliderOrientation::Horizontal => Key::ArrowLeft,
SliderOrientation::Vertical => Key::ArrowDown,
}
}
fn rail_rect(&self, rect: &Rect, radius: f32) -> Rect {
match self.orientation {
SliderOrientation::Horizontal => Rect::from_min_max(