diff options
author | RĂ©mi Verschelde <rverschelde@gmail.com> | 2017-01-02 13:52:31 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2017-01-02 13:52:31 +0100 |
commit | 1a2a57e2eedfc6b0dd06e70a0e0e9d4fef1014f2 (patch) | |
tree | 89109d0589846bf22214b77fa12dcb29ad44ac57 /scene/gui | |
parent | 2e87232f0a6860c24926af10f0001092f3a582e5 (diff) | |
parent | 22b76511fb4e26c3f6726bcb710b4df1d028d37d (diff) |
Merge pull request #7376 from volzhs/scroll-horizontal
Scroll horizontally with mouse wheel when horizontal enabled only
Diffstat (limited to 'scene/gui')
-rw-r--r-- | scene/gui/scroll_container.cpp | 20 |
1 files changed, 14 insertions, 6 deletions
diff --git a/scene/gui/scroll_container.cpp b/scene/gui/scroll_container.cpp index 388dc3e4e4..bad478a745 100644 --- a/scene/gui/scroll_container.cpp +++ b/scene/gui/scroll_container.cpp @@ -88,14 +88,22 @@ void ScrollContainer::_input_event(const InputEvent& p_input_event) { const InputEventMouseButton &mb=p_input_event.mouse_button; - if (mb.button_index==BUTTON_WHEEL_UP && mb.pressed && v_scroll->is_visible()) { - - v_scroll->set_val( v_scroll->get_val()-v_scroll->get_page()/8 ); + if (mb.button_index==BUTTON_WHEEL_UP && mb.pressed) { + if (h_scroll->is_visible() && !v_scroll->is_visible()){ + // only horizontal is enabled, scroll horizontally + h_scroll->set_val( h_scroll->get_val()-h_scroll->get_page()/8 ); + } else if (v_scroll->is_visible()) { + v_scroll->set_val( v_scroll->get_val()-v_scroll->get_page()/8 ); + } } - if (mb.button_index==BUTTON_WHEEL_DOWN && mb.pressed && v_scroll->is_visible()) { - - v_scroll->set_val( v_scroll->get_val()+v_scroll->get_page()/8 ); + if (mb.button_index==BUTTON_WHEEL_DOWN && mb.pressed) { + if (h_scroll->is_visible() && !v_scroll->is_visible()){ + // only horizontal is enabled, scroll horizontally + h_scroll->set_val( h_scroll->get_val()+h_scroll->get_page()/8 ); + } else if (v_scroll->is_visible()) { + v_scroll->set_val( v_scroll->get_val()+v_scroll->get_page()/8 ); + } } if(!OS::get_singleton()->has_touchscreen_ui_hint()) |