Add an option to drag'n'drop selected text in TextEdit
(cherry picked from commit 5d56efcaa4
)
This commit is contained in:
parent
510630651f
commit
a13b3028a2
5 changed files with 22 additions and 1 deletions
|
@ -495,6 +495,9 @@
|
|||
<member name="deselect_on_focus_loss_enabled" type="bool" setter="set_deselect_on_focus_loss_enabled" getter="is_deselect_on_focus_loss_enabled" default="true">
|
||||
If [code]true[/code], the selected text will be deselected when focus is lost.
|
||||
</member>
|
||||
<member name="drag_and_drop_selection_enabled" type="bool" setter="set_drag_and_drop_selection_enabled" getter="is_drag_and_drop_selection_enabled" default="true">
|
||||
If [code]true[/code], allow drag and drop of selected text.
|
||||
</member>
|
||||
<member name="draw_spaces" type="bool" setter="set_draw_spaces" getter="is_drawing_spaces" default="false">
|
||||
If [code]true[/code], the "space" character will have a visible representation.
|
||||
</member>
|
||||
|
|
|
@ -923,6 +923,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"));
|
||||
|
|
|
@ -438,6 +438,7 @@ void EditorSettings::_load_defaults(Ref<ConfigFile> 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);
|
||||
|
|
|
@ -2581,7 +2581,7 @@ void TextEdit::_gui_input(const Ref<InputEvent> &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 {
|
||||
|
@ -7362,6 +7362,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;
|
||||
}
|
||||
|
@ -7478,6 +7486,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);
|
||||
|
@ -7592,6 +7602,7 @@ void TextEdit::_bind_methods() {
|
|||
ADD_PROPERTY(PropertyInfo(Variant::BOOL, "middle_mouse_paste_enabled"), "set_middle_mouse_paste_enabled", "is_middle_mouse_paste_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");
|
||||
|
|
|
@ -438,6 +438,7 @@ private:
|
|||
|
||||
bool selecting_enabled;
|
||||
bool deselect_on_focus_loss_enabled;
|
||||
bool drag_and_drop_selection_enabled = true;
|
||||
bool popup_show = false;
|
||||
|
||||
bool context_menu_enabled;
|
||||
|
@ -762,6 +763,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;
|
||||
|
||||
|
@ -861,6 +863,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;
|
||||
|
||||
|
|
Loading…
Reference in a new issue