summaryrefslogtreecommitdiff
path: root/scene/gui
diff options
context:
space:
mode:
authorFabio Alessandrelli <fabio.alessandrelli@gmail.com>2018-02-23 12:10:23 +0100
committerFabio Alessandrelli <fabio.alessandrelli@gmail.com>2018-02-23 13:01:28 +0100
commit59c23c136949afe6c08f601e30af8ae6d40e5949 (patch)
treebd80f2f01e0d427a50fad8e1e33baf90341657c8 /scene/gui
parente15fe296bdbcbab038fe0a918a3cb739826e8271 (diff)
Scrollbar now uses UI actions instead of keys
Diffstat (limited to 'scene/gui')
-rw-r--r--scene/gui/scroll_bar.cpp57
1 files changed, 26 insertions, 31 deletions
diff --git a/scene/gui/scroll_bar.cpp b/scene/gui/scroll_bar.cpp
index 95fcda2db3..94e149c8a7 100644
--- a/scene/gui/scroll_bar.cpp
+++ b/scene/gui/scroll_bar.cpp
@@ -201,52 +201,47 @@ void ScrollBar::_gui_input(Ref<InputEvent> p_event) {
Ref<InputEventKey> k = p_event;
- if (k.is_valid()) {
+ if (p_event->is_pressed()) {
- if (!k->is_pressed())
- return;
-
- switch (k->get_scancode()) {
+ if (p_event->is_action("ui_left")) {
- case KEY_LEFT: {
+ if (orientation != HORIZONTAL)
+ return;
+ set_value(get_value() - (custom_step >= 0 ? custom_step : get_step()));
- if (orientation != HORIZONTAL)
- return;
- set_value(get_value() - (custom_step >= 0 ? custom_step : get_step()));
+ } else if (p_event->is_action("ui_right")) {
- } break;
- case KEY_RIGHT: {
+ if (orientation != HORIZONTAL)
+ return;
+ set_value(get_value() + (custom_step >= 0 ? custom_step : get_step()));
- if (orientation != HORIZONTAL)
- return;
- set_value(get_value() + (custom_step >= 0 ? custom_step : get_step()));
+ } else if (p_event->is_action("ui_up")) {
- } break;
- case KEY_UP: {
+ if (orientation != VERTICAL)
+ return;
- if (orientation != VERTICAL)
- return;
+ set_value(get_value() - (custom_step >= 0 ? custom_step : get_step()));
- set_value(get_value() - (custom_step >= 0 ? custom_step : get_step()));
+ } else if (p_event->is_action("ui_down")) {
- } break;
- case KEY_DOWN: {
+ if (orientation != VERTICAL)
+ return;
+ set_value(get_value() + (custom_step >= 0 ? custom_step : get_step()));
- if (orientation != VERTICAL)
- return;
- set_value(get_value() + (custom_step >= 0 ? custom_step : get_step()));
+ } else if (k.is_valid()) {
- } break;
- case KEY_HOME: {
+ switch (k->get_scancode()) {
+ case KEY_HOME: {
- set_value(get_min());
+ set_value(get_min());
- } break;
- case KEY_END: {
+ } break;
+ case KEY_END: {
- set_value(get_max());
+ set_value(get_max());
- } break;
+ } break;
+ }
}
}
}