summaryrefslogtreecommitdiff
path: root/scene/gui/scroll_bar.cpp
diff options
context:
space:
mode:
authorFabio Alessandrelli <fabio.alessandrelli@gmail.com>2018-03-16 20:55:11 +0100
committerGitHub <noreply@github.com>2018-03-16 20:55:11 +0100
commitc531262190d7b75238e60565a3a59f13feed2ffa (patch)
tree8bed4bea6d93cb8478a9a4cda0cd6f746014d318 /scene/gui/scroll_bar.cpp
parente06a56eac8c1fbf36e985697d3b6b1a66ec8ac0e (diff)
parent920d2bfdfa582b81b0e47d8a0a5de5817289c6dc (diff)
Merge pull request #16947 from Faless/ui_actions
GUI elements ui_action usage, improvements
Diffstat (limited to 'scene/gui/scroll_bar.cpp')
-rw-r--r--scene/gui/scroll_bar.cpp56
1 files changed, 21 insertions, 35 deletions
diff --git a/scene/gui/scroll_bar.cpp b/scene/gui/scroll_bar.cpp
index 95fcda2db3..e1cabd3f88 100644
--- a/scene/gui/scroll_bar.cpp
+++ b/scene/gui/scroll_bar.cpp
@@ -199,54 +199,40 @@ void ScrollBar::_gui_input(Ref<InputEvent> p_event) {
}
}
- Ref<InputEventKey> k = p_event;
+ if (p_event->is_pressed()) {
- if (k.is_valid()) {
+ if (p_event->is_action("ui_left")) {
- if (!k->is_pressed())
- return;
-
- switch (k->get_scancode()) {
-
- 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()));
- } break;
- case KEY_RIGHT: {
+ } else if (p_event->is_action("ui_right")) {
- if (orientation != HORIZONTAL)
- return;
- set_value(get_value() + (custom_step >= 0 ? custom_step : get_step()));
-
- } break;
- case KEY_UP: {
+ if (orientation != HORIZONTAL)
+ return;
+ set_value(get_value() + (custom_step >= 0 ? custom_step : get_step()));
- if (orientation != VERTICAL)
- return;
+ } else if (p_event->is_action("ui_up")) {
- set_value(get_value() - (custom_step >= 0 ? custom_step : get_step()));
+ if (orientation != VERTICAL)
+ return;
- } break;
- case KEY_DOWN: {
+ 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 (p_event->is_action("ui_down")) {
- } break;
- case KEY_HOME: {
+ if (orientation != VERTICAL)
+ return;
+ set_value(get_value() + (custom_step >= 0 ? custom_step : get_step()));
- set_value(get_min());
+ } else if (p_event->is_action("ui_home")) {
- } break;
- case KEY_END: {
+ set_value(get_min());
- set_value(get_max());
+ } else if (p_event->is_action("ui_end")) {
- } break;
+ set_value(get_max());
}
}
}