Scroll faster when holding Alt in TextEdit (and script editor)

This feature is inspired by a similar feature found in
Visual Studio Code.

(cherry picked from commit cf1cf6c6eb)
This commit is contained in:
Hugo Locurcio
2021-05-10 01:27:54 +02:00
committed by Rémi Verschelde
parent 57fdddecff
commit 333dfb96da
2 changed files with 11 additions and 2 deletions

View File

@@ -2326,14 +2326,22 @@ void TextEdit::_gui_input(const Ref<InputEvent> &p_gui_input) {
if (mb->get_button_index() == BUTTON_WHEEL_UP && !mb->get_command()) {
if (mb->get_shift()) {
h_scroll->set_value(h_scroll->get_value() - (100 * mb->get_factor()));
} else if (mb->get_alt()) {
// Scroll 5 times as fast as normal (like in Visual Studio Code).
_scroll_up(15 * mb->get_factor());
} else if (v_scroll->is_visible()) {
// Scroll 3 lines.
_scroll_up(3 * mb->get_factor());
}
}
if (mb->get_button_index() == BUTTON_WHEEL_DOWN && !mb->get_command()) {
if (mb->get_shift()) {
h_scroll->set_value(h_scroll->get_value() + (100 * mb->get_factor()));
} else if (mb->get_alt()) {
// Scroll 5 times as fast as normal (like in Visual Studio Code).
_scroll_down(15 * mb->get_factor());
} else if (v_scroll->is_visible()) {
// Scroll 3 lines.
_scroll_down(3 * mb->get_factor());
}
}