You've already forked godot
mirror of
https://github.com/godotengine/godot.git
synced 2025-11-05 12:10:55 +00:00
Merge pull request #90743 from timothyqiu/empty-selection-clipboard
Add TextEdit option to prevent copying without a selection
This commit is contained in:
@@ -3367,6 +3367,14 @@ bool TextEdit::is_middle_mouse_paste_enabled() const {
|
||||
return middle_mouse_paste_enabled;
|
||||
}
|
||||
|
||||
void TextEdit::set_empty_selection_clipboard_enabled(bool p_enabled) {
|
||||
empty_selection_clipboard_enabled = p_enabled;
|
||||
}
|
||||
|
||||
bool TextEdit::is_empty_selection_clipboard_enabled() const {
|
||||
return empty_selection_clipboard_enabled;
|
||||
}
|
||||
|
||||
// Text manipulation
|
||||
void TextEdit::clear() {
|
||||
setting_text = true;
|
||||
@@ -6569,6 +6577,9 @@ void TextEdit::_bind_methods() {
|
||||
ClassDB::bind_method(D_METHOD("set_middle_mouse_paste_enabled", "enabled"), &TextEdit::set_middle_mouse_paste_enabled);
|
||||
ClassDB::bind_method(D_METHOD("is_middle_mouse_paste_enabled"), &TextEdit::is_middle_mouse_paste_enabled);
|
||||
|
||||
ClassDB::bind_method(D_METHOD("set_empty_selection_clipboard_enabled", "enabled"), &TextEdit::set_empty_selection_clipboard_enabled);
|
||||
ClassDB::bind_method(D_METHOD("is_empty_selection_clipboard_enabled"), &TextEdit::is_empty_selection_clipboard_enabled);
|
||||
|
||||
// Text manipulation
|
||||
ClassDB::bind_method(D_METHOD("clear"), &TextEdit::clear);
|
||||
|
||||
@@ -6962,6 +6973,7 @@ void TextEdit::_bind_methods() {
|
||||
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, "virtual_keyboard_enabled"), "set_virtual_keyboard_enabled", "is_virtual_keyboard_enabled");
|
||||
ADD_PROPERTY(PropertyInfo(Variant::BOOL, "middle_mouse_paste_enabled"), "set_middle_mouse_paste_enabled", "is_middle_mouse_paste_enabled");
|
||||
ADD_PROPERTY(PropertyInfo(Variant::BOOL, "empty_selection_clipboard_enabled"), "set_empty_selection_clipboard_enabled", "is_empty_selection_clipboard_enabled");
|
||||
ADD_PROPERTY(PropertyInfo(Variant::INT, "wrap_mode", PROPERTY_HINT_ENUM, "None,Boundary"), "set_line_wrapping_mode", "get_line_wrapping_mode");
|
||||
ADD_PROPERTY(PropertyInfo(Variant::INT, "autowrap_mode", PROPERTY_HINT_ENUM, "Arbitrary:1,Word:2,Word (Smart):3"), "set_autowrap_mode", "get_autowrap_mode");
|
||||
ADD_PROPERTY(PropertyInfo(Variant::BOOL, "indent_wrapped_lines"), "set_indent_wrapped_lines", "is_indent_wrapped_lines");
|
||||
@@ -7216,6 +7228,10 @@ void TextEdit::_cut_internal(int p_caret) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (!empty_selection_clipboard_enabled) {
|
||||
return;
|
||||
}
|
||||
|
||||
// Remove full lines.
|
||||
begin_complex_operation();
|
||||
begin_multicaret_edit();
|
||||
@@ -7246,6 +7262,10 @@ void TextEdit::_copy_internal(int p_caret) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (!empty_selection_clipboard_enabled) {
|
||||
return;
|
||||
}
|
||||
|
||||
// Copy full lines.
|
||||
StringBuilder clipboard;
|
||||
Vector<Point2i> line_ranges;
|
||||
|
||||
Reference in New Issue
Block a user