diff options
Diffstat (limited to 'scene/gui/scroll_container.cpp')
-rw-r--r-- | scene/gui/scroll_container.cpp | 30 |
1 files changed, 21 insertions, 9 deletions
diff --git a/scene/gui/scroll_container.cpp b/scene/gui/scroll_container.cpp index 9146fa9393..a89c2b27c9 100644 --- a/scene/gui/scroll_container.cpp +++ b/scene/gui/scroll_container.cpp @@ -85,20 +85,32 @@ void ScrollContainer::_gui_input(const InputEvent &p_gui_input) { const InputEventMouseButton &mb = p_gui_input.mouse_button; if (mb.button_index == BUTTON_WHEEL_UP && mb.pressed) { - if (h_scroll->is_visible_in_tree() && !v_scroll->is_visible_in_tree()) { - // only horizontal is enabled, scroll horizontally - h_scroll->set_value(h_scroll->get_value() - h_scroll->get_page() / 8); + // only horizontal is enabled, scroll horizontally + if (h_scroll->is_visible() && !v_scroll->is_visible()) { + h_scroll->set_value(h_scroll->get_value() - h_scroll->get_page() / 8 * mb.factor); } else if (v_scroll->is_visible_in_tree()) { - v_scroll->set_value(v_scroll->get_value() - v_scroll->get_page() / 8); + v_scroll->set_value(v_scroll->get_value() - v_scroll->get_page() / 8 * mb.factor); } } if (mb.button_index == BUTTON_WHEEL_DOWN && mb.pressed) { - if (h_scroll->is_visible_in_tree() && !v_scroll->is_visible_in_tree()) { - // only horizontal is enabled, scroll horizontally - h_scroll->set_value(h_scroll->get_value() + h_scroll->get_page() / 8); - } else if (v_scroll->is_visible_in_tree()) { - v_scroll->set_value(v_scroll->get_value() + v_scroll->get_page() / 8); + // only horizontal is enabled, scroll horizontally + if (h_scroll->is_visible() && !v_scroll->is_visible()) { + h_scroll->set_value(h_scroll->get_value() + h_scroll->get_page() / 8 * mb.factor); + } else if (v_scroll->is_visible()) { + v_scroll->set_value(v_scroll->get_value() + v_scroll->get_page() / 8 * mb.factor); + } + } + + if (mb.button_index == BUTTON_WHEEL_LEFT && mb.pressed) { + if (h_scroll->is_visible_in_tree()) { + h_scroll->set_value(h_scroll->get_value() - h_scroll->get_page() * mb.factor / 8); + } + } + + if (mb.button_index == BUTTON_WHEEL_RIGHT && mb.pressed) { + if (h_scroll->is_visible_in_tree()) { + h_scroll->set_value(h_scroll->get_value() + h_scroll->get_page() * mb.factor / 8); } } |