diff options
author | Hugo Locurcio <hugo.locurcio@hugo.pro> | 2021-05-10 01:27:54 +0200 |
---|---|---|
committer | Hugo Locurcio <hugo.locurcio@hugo.pro> | 2021-05-10 01:27:54 +0200 |
commit | cf1cf6c6eb77edc3dc119c3677e14f4d42460263 (patch) | |
tree | 0d2c9db07d5d269447067724e6b68ad85fd11b7a | |
parent | 6e3f47983cabb5f162eaec075d810f717985beda (diff) |
Scroll faster when holding Alt in TextEdit (and script editor)
This feature is inspired by a similar feature found in
Visual Studio Code.
-rw-r--r-- | doc/classes/TextEdit.xml | 5 | ||||
-rw-r--r-- | scene/gui/text_edit.cpp | 8 |
2 files changed, 11 insertions, 2 deletions
diff --git a/doc/classes/TextEdit.xml b/doc/classes/TextEdit.xml index 088bcd1c3c..e2467b84a1 100644 --- a/doc/classes/TextEdit.xml +++ b/doc/classes/TextEdit.xml @@ -5,6 +5,7 @@ </brief_description> <description> TextEdit is meant for editing large, multiline text. It also has facilities for editing code, such as syntax highlighting support and multiple levels of undo/redo. + [b]Note:[/b] When holding down [kbd]Alt[/kbd], the vertical scroll wheel will scroll 5 times as fast as it would normally do. This also works in the Godot script editor. </description> <tutorials> </tutorials> @@ -714,10 +715,10 @@ If [code]true[/code], read-only mode is enabled. Existing text cannot be modified and new text cannot be added. </member> <member name="scroll_horizontal" type="int" setter="set_h_scroll" getter="get_h_scroll" default="0"> - If there is a horizontal scrollbar this determines the current horizontal scroll value in pixels. + If there is a horizontal scrollbar, this determines the current horizontal scroll value in pixels. </member> <member name="scroll_vertical" type="float" setter="set_v_scroll" getter="get_v_scroll" default="0.0"> - If there is a vertical scrollbar this determines the current vertical scroll value in line numbers, starting at 0 for the top line. + If there is a vertical scrollbar, this determines the current vertical scroll value in line numbers, starting at 0 for the top line. </member> <member name="selecting_enabled" type="bool" setter="set_selecting_enabled" getter="is_selecting_enabled" default="true"> If [code]true[/code], text can be selected. diff --git a/scene/gui/text_edit.cpp b/scene/gui/text_edit.cpp index c924f89709..045480bedb 100644 --- a/scene/gui/text_edit.cpp +++ b/scene/gui/text_edit.cpp @@ -2917,14 +2917,22 @@ void TextEdit::_gui_input(const Ref<InputEvent> &p_gui_input) { if (mb->get_button_index() == MOUSE_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() == MOUSE_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()); } } |