summaryrefslogtreecommitdiffstats
path: root/scene
diff options
context:
space:
mode:
authorHaoyu Qiu <timothyqiu32@gmail.com>2024-09-19 08:14:00 +0800
committerHaoyu Qiu <timothyqiu32@gmail.com>2024-09-19 19:21:29 +0800
commit14321b8ed5e151987c0e2a0dd28d7a4e2483faba (patch)
tree9506b0a903bd48eb925506942bfddbde7a6ddb22 /scene
parent694d3c2930bdfb43fd93e1e6641f66c4f19a5c77 (diff)
downloadredot-engine-14321b8ed5e151987c0e2a0dd28d7a4e2483faba.tar.gz
Set auto translate mode for drag previews
- Controls - `LineEdit`, `TextEdit`: Always disabled since it's dragging user input. - `TabBar`: Use the same auto translate mode as the node. - `RichTextLabel`: Always disable since auto translation is done differently from other controls (selection text you get programmatically is always after auto translation). - Editor - Disable drag preview auto translation if the text is user input, filename, or class name. - Also disabled unexpected auto translation for audio bus effect names.
Diffstat (limited to 'scene')
-rw-r--r--scene/gui/line_edit.cpp1
-rw-r--r--scene/gui/rich_text_label.cpp1
-rw-r--r--scene/gui/tab_bar.cpp1
-rw-r--r--scene/gui/text_edit.cpp1
4 files changed, 4 insertions, 0 deletions
diff --git a/scene/gui/line_edit.cpp b/scene/gui/line_edit.cpp
index a08fb96e71..ae709cf7a4 100644
--- a/scene/gui/line_edit.cpp
+++ b/scene/gui/line_edit.cpp
@@ -921,6 +921,7 @@ Variant LineEdit::get_drag_data(const Point2 &p_point) {
String t = get_selected_text();
Label *l = memnew(Label);
l->set_text(t);
+ l->set_auto_translate_mode(AUTO_TRANSLATE_MODE_DISABLED); // Don't translate user input.
set_drag_preview(l);
return t;
}
diff --git a/scene/gui/rich_text_label.cpp b/scene/gui/rich_text_label.cpp
index 0c3c90d070..e302927692 100644
--- a/scene/gui/rich_text_label.cpp
+++ b/scene/gui/rich_text_label.cpp
@@ -5431,6 +5431,7 @@ Variant RichTextLabel::get_drag_data(const Point2 &p_point) {
String t = get_selected_text();
Label *l = memnew(Label);
l->set_text(t);
+ l->set_auto_translate_mode(AUTO_TRANSLATE_MODE_DISABLED); // Text is already translated.
set_drag_preview(l);
return t;
}
diff --git a/scene/gui/tab_bar.cpp b/scene/gui/tab_bar.cpp
index 3e0d6adf42..90bb0799b1 100644
--- a/scene/gui/tab_bar.cpp
+++ b/scene/gui/tab_bar.cpp
@@ -1250,6 +1250,7 @@ Variant TabBar::_handle_get_drag_data(const String &p_type, const Point2 &p_poin
}
Label *label = memnew(Label(get_tab_title(tab_over)));
+ label->set_auto_translate_mode(get_auto_translate_mode()); // Reflect how the title is displayed.
drag_preview->add_child(label);
set_drag_preview(drag_preview);
diff --git a/scene/gui/text_edit.cpp b/scene/gui/text_edit.cpp
index bf9c479c69..888e680219 100644
--- a/scene/gui/text_edit.cpp
+++ b/scene/gui/text_edit.cpp
@@ -3034,6 +3034,7 @@ Variant TextEdit::get_drag_data(const Point2 &p_point) {
if (has_selection() && selection_drag_attempt) {
String t = get_selected_text();
Label *l = memnew(Label);
+ l->set_auto_translate_mode(AUTO_TRANSLATE_MODE_DISABLED); // Don't translate user input.
l->set_text(t);
set_drag_preview(l);
return t;