aboutsummaryrefslogtreecommitdiff
path: root/editor/plugins/shader_editor_plugin.cpp
diff options
context:
space:
mode:
authorMattUV2017-12-20 02:36:47 +0100
committerMattUV2017-12-20 09:01:09 +0100
commita55870cd815d065acea099cf0baecaaf51aa1b16 (patch)
tree8dae6ef8be753a553882dbaad72cd99cba98f86e /editor/plugins/shader_editor_plugin.cpp
parent06dd10b3905a7d48beffe0523b785d513747f511 (diff)
downloadgodot-a55870cd815d065acea099cf0baecaaf51aa1b16.tar.gz
godot-a55870cd815d065acea099cf0baecaaf51aa1b16.tar.zst
godot-a55870cd815d065acea099cf0baecaaf51aa1b16.zip
Diffstat (limited to 'editor/plugins/shader_editor_plugin.cpp')
-rw-r--r--editor/plugins/shader_editor_plugin.cpp28
1 files changed, 25 insertions, 3 deletions
diff --git a/editor/plugins/shader_editor_plugin.cpp b/editor/plugins/shader_editor_plugin.cpp
index 3e00776df..d0b0d3690 100644
--- a/editor/plugins/shader_editor_plugin.cpp
+++ b/editor/plugins/shader_editor_plugin.cpp
@@ -620,14 +620,36 @@ void ShaderEditor::_text_edit_gui_input(const Ref<InputEvent> &ev) {
if (mb.is_valid()) {
- if (mb->get_button_index() == BUTTON_RIGHT && !mb->is_pressed()) {
+ if (mb->get_button_index() == BUTTON_RIGHT) {
int col, row;
TextEdit *tx = shader_editor->get_text_edit();
tx->_get_mouse_pos(mb->get_global_position() - tx->get_global_position(), row, col);
Vector2 mpos = mb->get_global_position() - tx->get_global_position();
- bool have_selection = (tx->get_selection_text().length() > 0);
- _make_context_menu(have_selection);
+ tx->set_right_click_moves_caret(EditorSettings::get_singleton()->get("text_editor/cursor/right_click_moves_caret"));
+
+ if (tx->is_right_click_moving_caret()) {
+ if (tx->is_selection_active()) {
+
+ int from_line = tx->get_selection_from_line();
+ int to_line = tx->get_selection_to_line();
+ int from_column = tx->get_selection_from_column();
+ int to_column = tx->get_selection_to_column();
+
+ if (row < from_line || row > to_line || (row == from_line && col < from_column) || (row == to_line && col > to_column)) {
+ // Right click is outside the seleted text
+ tx->deselect();
+ }
+ }
+ if (!tx->is_selection_active()) {
+ tx->cursor_set_line(row, true, false);
+ tx->cursor_set_column(col);
+ }
+ }
+
+ if (!mb->is_pressed()) {
+ _make_context_menu(tx->is_selection_active());
+ }
}
}
}