diff options
Diffstat (limited to 'scene')
-rw-r--r-- | scene/gui/scroll_bar.cpp | 17 | ||||
-rw-r--r-- | scene/gui/slider.cpp | 26 |
2 files changed, 10 insertions, 33 deletions
diff --git a/scene/gui/scroll_bar.cpp b/scene/gui/scroll_bar.cpp index 94e149c8a7..e1cabd3f88 100644 --- a/scene/gui/scroll_bar.cpp +++ b/scene/gui/scroll_bar.cpp @@ -199,8 +199,6 @@ void ScrollBar::_gui_input(Ref<InputEvent> p_event) { } } - Ref<InputEventKey> k = p_event; - if (p_event->is_pressed()) { if (p_event->is_action("ui_left")) { @@ -228,20 +226,13 @@ void ScrollBar::_gui_input(Ref<InputEvent> p_event) { return; set_value(get_value() + (custom_step >= 0 ? custom_step : get_step())); - } else if (k.is_valid()) { - - switch (k->get_scancode()) { - case KEY_HOME: { + } else if (p_event->is_action("ui_home")) { - set_value(get_min()); + set_value(get_min()); - } break; - case KEY_END: { + } else if (p_event->is_action("ui_end")) { - set_value(get_max()); - - } break; - } + set_value(get_max()); } } } diff --git a/scene/gui/slider.cpp b/scene/gui/slider.cpp index a7a1b499c3..46215c9277 100644 --- a/scene/gui/slider.cpp +++ b/scene/gui/slider.cpp @@ -118,28 +118,14 @@ void Slider::_gui_input(Ref<InputEvent> p_event) { return; set_value(get_value() - (custom_step >= 0 ? custom_step : get_step())); accept_event(); + } else if (p_event->is_action("ui_home") && p_event->is_pressed()) { - } else { - - Ref<InputEventKey> k = p_event; - - if (!k.is_valid() || !k->is_pressed()) - return; - - switch (k->get_scancode()) { - - case KEY_HOME: { - - set_value(get_min()); - accept_event(); - } break; - case KEY_END: { - - set_value(get_max()); - accept_event(); + set_value(get_min()); + accept_event(); + } else if (p_event->is_action("ui_end") && p_event->is_pressed()) { - } break; - } + set_value(get_max()); + accept_event(); } } } |