mirror of
https://github.com/godotengine/godot.git
synced 2025-12-08 06:09:55 +00:00
Implemented scrolling factor for smooth trackpad scrolling
Working platforms platform: OSX, Windows.
Support for almost all ui elements, including project list.
Ported from 304a1f5b5a (#7864).
Fixes #492 and #3913.
This commit is contained in:
parent
e7328fe5a0
commit
ee670f3724
15 changed files with 111 additions and 67 deletions
|
|
@ -85,20 +85,32 @@ 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) {
|
||||
// only horizontal is enabled, scroll horizontally
|
||||
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);
|
||||
h_scroll->set_val(h_scroll->get_val() - h_scroll->get_page() / 8 * mb.factor);
|
||||
} else if (v_scroll->is_visible()) {
|
||||
v_scroll->set_val(v_scroll->get_val() - v_scroll->get_page() / 8);
|
||||
v_scroll->set_val(v_scroll->get_val() - v_scroll->get_page() / 8 * mb.factor);
|
||||
}
|
||||
}
|
||||
|
||||
if (mb.button_index == BUTTON_WHEEL_DOWN && mb.pressed) {
|
||||
// only horizontal is enabled, scroll horizontally
|
||||
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);
|
||||
h_scroll->set_val(h_scroll->get_val() + h_scroll->get_page() / 8 * mb.factor);
|
||||
} else if (v_scroll->is_visible()) {
|
||||
v_scroll->set_val(v_scroll->get_val() + v_scroll->get_page() / 8);
|
||||
v_scroll->set_val(v_scroll->get_val() + v_scroll->get_page() / 8 * mb.factor);
|
||||
}
|
||||
}
|
||||
|
||||
if (mb.button_index == BUTTON_WHEEL_LEFT && mb.pressed) {
|
||||
if (h_scroll->is_visible()) {
|
||||
h_scroll->set_val(h_scroll->get_val() - h_scroll->get_page() * mb.factor / 8);
|
||||
}
|
||||
}
|
||||
|
||||
if (mb.button_index == BUTTON_WHEEL_RIGHT && mb.pressed) {
|
||||
if (h_scroll->is_visible()) {
|
||||
h_scroll->set_val(h_scroll->get_val() + h_scroll->get_page() * mb.factor / 8);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue