diff --git a/doc/classes/TextEdit.xml b/doc/classes/TextEdit.xml index 0f0218da1..64b269f0f 100644 --- a/doc/classes/TextEdit.xml +++ b/doc/classes/TextEdit.xml @@ -495,6 +495,9 @@ If [code]true[/code], the selected text will be deselected when focus is lost. + + If [code]true[/code], allow drag and drop of selected text. + If [code]true[/code], the "space" character will have a visible representation. diff --git a/editor/code_editor.cpp b/editor/code_editor.cpp index 45ae0de52..5ff6ccc8b 100644 --- a/editor/code_editor.cpp +++ b/editor/code_editor.cpp @@ -948,6 +948,7 @@ void CodeTextEditor::update_editor_settings() { text_editor->set_v_scroll_speed(EditorSettings::get_singleton()->get("text_editor/navigation/v_scroll_speed")); text_editor->set_draw_minimap(EditorSettings::get_singleton()->get("text_editor/navigation/show_minimap")); text_editor->set_minimap_width((int)EditorSettings::get_singleton()->get("text_editor/navigation/minimap_width") * EDSCALE); + text_editor->set_drag_and_drop_selection_enabled(EditorSettings::get_singleton()->get("text_editor/navigation/drag_and_drop_selection")); text_editor->set_show_line_numbers(EditorSettings::get_singleton()->get("text_editor/appearance/show_line_numbers")); text_editor->set_line_numbers_zero_padded(EditorSettings::get_singleton()->get("text_editor/appearance/line_numbers_zero_padded")); text_editor->set_bookmark_gutter_enabled(EditorSettings::get_singleton()->get("text_editor/appearance/show_bookmark_gutter")); diff --git a/editor/editor_settings.cpp b/editor/editor_settings.cpp index 62004f8a1..5faef22cc 100644 --- a/editor/editor_settings.cpp +++ b/editor/editor_settings.cpp @@ -453,6 +453,7 @@ void EditorSettings::_load_defaults(Ref p_extra_config) { _initial_set("text_editor/navigation/minimap_width", 80); hints["text_editor/navigation/minimap_width"] = PropertyInfo(Variant::INT, "text_editor/navigation/minimap_width", PROPERTY_HINT_RANGE, "50,250,1"); _initial_set("text_editor/navigation/mouse_extra_buttons_navigate_history", true); + _initial_set("text_editor/navigation/drag_and_drop_selection", true); // Appearance _initial_set("text_editor/appearance/show_line_numbers", true); diff --git a/scene/gui/text_edit.cpp b/scene/gui/text_edit.cpp index 0b362aa18..e81b050f2 100644 --- a/scene/gui/text_edit.cpp +++ b/scene/gui/text_edit.cpp @@ -2580,7 +2580,7 @@ void TextEdit::_gui_input(const Ref &p_gui_input) { update(); } - } else if (is_mouse_over_selection()) { + } else if (drag_and_drop_selection_enabled && is_mouse_over_selection()) { selection.selecting_mode = Selection::MODE_NONE; selection.drag_attempt = true; } else { @@ -7339,6 +7339,14 @@ bool TextEdit::is_deselect_on_focus_loss_enabled() const { return deselect_on_focus_loss_enabled; } +void TextEdit::set_drag_and_drop_selection_enabled(const bool p_enabled) { + drag_and_drop_selection_enabled = p_enabled; +} + +bool TextEdit::is_drag_and_drop_selection_enabled() const { + return drag_and_drop_selection_enabled; +} + bool TextEdit::is_shortcut_keys_enabled() const { return shortcut_keys_enabled; } @@ -7449,6 +7457,8 @@ void TextEdit::_bind_methods() { ClassDB::bind_method(D_METHOD("is_selecting_enabled"), &TextEdit::is_selecting_enabled); ClassDB::bind_method(D_METHOD("set_deselect_on_focus_loss_enabled", "enable"), &TextEdit::set_deselect_on_focus_loss_enabled); ClassDB::bind_method(D_METHOD("is_deselect_on_focus_loss_enabled"), &TextEdit::is_deselect_on_focus_loss_enabled); + ClassDB::bind_method(D_METHOD("set_drag_and_drop_selection_enabled", "enable"), &TextEdit::set_drag_and_drop_selection_enabled); + ClassDB::bind_method(D_METHOD("is_drag_and_drop_selection_enabled"), &TextEdit::is_drag_and_drop_selection_enabled); ClassDB::bind_method(D_METHOD("is_line_set_as_safe", "line"), &TextEdit::is_line_set_as_safe); ClassDB::bind_method(D_METHOD("set_line_as_safe", "line", "safe"), &TextEdit::set_line_as_safe); ClassDB::bind_method(D_METHOD("is_line_set_as_bookmark", "line"), &TextEdit::is_line_set_as_bookmark); @@ -7562,6 +7572,7 @@ void TextEdit::_bind_methods() { ADD_PROPERTY(PropertyInfo(Variant::BOOL, "virtual_keyboard_enabled"), "set_virtual_keyboard_enabled", "is_virtual_keyboard_enabled"); ADD_PROPERTY(PropertyInfo(Variant::BOOL, "selecting_enabled"), "set_selecting_enabled", "is_selecting_enabled"); ADD_PROPERTY(PropertyInfo(Variant::BOOL, "deselect_on_focus_loss_enabled"), "set_deselect_on_focus_loss_enabled", "is_deselect_on_focus_loss_enabled"); + ADD_PROPERTY(PropertyInfo(Variant::BOOL, "drag_and_drop_selection_enabled"), "set_drag_and_drop_selection_enabled", "is_drag_and_drop_selection_enabled"); ADD_PROPERTY(PropertyInfo(Variant::BOOL, "smooth_scrolling"), "set_smooth_scroll_enable", "is_smooth_scroll_enabled"); ADD_PROPERTY(PropertyInfo(Variant::REAL, "v_scroll_speed"), "set_v_scroll_speed", "get_v_scroll_speed"); ADD_PROPERTY(PropertyInfo(Variant::BOOL, "hiding_enabled"), "set_hiding_enabled", "is_hiding_enabled"); @@ -7731,6 +7742,7 @@ TextEdit::TextEdit() { selecting_enabled = true; deselect_on_focus_loss_enabled = true; + drag_and_drop_selection_enabled = true; popup_show = false; context_menu_enabled = true; shortcut_keys_enabled = true; diff --git a/scene/gui/text_edit.h b/scene/gui/text_edit.h index d124eba6a..af51f5bf0 100644 --- a/scene/gui/text_edit.h +++ b/scene/gui/text_edit.h @@ -438,6 +438,7 @@ private: bool selecting_enabled; bool deselect_on_focus_loss_enabled; + bool drag_and_drop_selection_enabled; bool popup_show; bool context_menu_enabled; @@ -760,6 +761,7 @@ public: bool is_drawing_tabs() const; void set_draw_spaces(bool p_draw); bool is_drawing_spaces() const; + void set_override_selected_font_color(bool p_override_selected_font_color); bool is_overriding_selected_font_color() const; @@ -859,6 +861,9 @@ public: void set_deselect_on_focus_loss_enabled(const bool p_enabled); bool is_deselect_on_focus_loss_enabled() const; + void set_drag_and_drop_selection_enabled(const bool p_enabled); + bool is_drag_and_drop_selection_enabled() const; + void set_shortcut_keys_enabled(bool p_enabled); bool is_shortcut_keys_enabled() const;