From 39141e7b9c20e13bf6ef36452e2d76cd550095b4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=A3=8E=E9=9D=92=E5=B1=B1?= Date: Sun, 10 Aug 2025 09:43:02 +0800 Subject: [PATCH] Disallow clicking to toggle the checkbox of a theme override of type `Resource` to checked These resources are external, but can be further categorized as follows: 1. Imported resource; 2. Embedded resource (no resource path, provided by the engine); 3. Other text-based resource. Resources of different categorie may need different strategies. Currently, for resource types, it is up to the user to decide what to do next. Clicking to toggle checkboxes is not allowed, but you can still manipulate resources through the `EditorResourcePicker`'s context menu (right-click on a resource in the inspector or click the down arrow icon next to the resource to open the menu). --- editor/inspector/editor_inspector.cpp | 32 +++++++++++++++++++-------- 1 file changed, 23 insertions(+), 9 deletions(-) diff --git a/editor/inspector/editor_inspector.cpp b/editor/inspector/editor_inspector.cpp index fb28ec57c9..48c16385ec 100644 --- a/editor/inspector/editor_inspector.cpp +++ b/editor/inspector/editor_inspector.cpp @@ -39,6 +39,7 @@ #include "editor/editor_node.h" #include "editor/editor_string_names.h" #include "editor/editor_undo_redo_manager.h" +#include "editor/gui/editor_toaster.h" #include "editor/gui/editor_validation_panel.h" #include "editor/inspector/add_metadata_dialog.h" #include "editor/inspector/editor_properties.h" @@ -1062,6 +1063,16 @@ void EditorProperty::gui_input(const Ref &p_event) { if (check_rect.has_point(mpos)) { accept_event(); + if (!checked && Object::cast_to(object) && property_path.begins_with("theme_override_")) { + List pinfo; + object->get_property_list(&pinfo); + for (const PropertyInfo &E : pinfo) { + if (E.type == Variant::OBJECT && E.name == property_path) { + EditorToaster::get_singleton()->popup_str(TTR("Toggling the checkbox is disabled for Resource properties. Modify the property using the resource picker instead."), EditorToaster::SEVERITY_WARNING); + return; // Disallow clicking to toggle the checkbox of type Resource to checked. + } + } + } checked = !checked; queue_redraw(); emit_signal(SNAME("property_checked"), property, checked); @@ -1080,6 +1091,17 @@ void EditorProperty::gui_input(const Ref &p_event) { void EditorProperty::_accessibility_action_click(const Variant &p_data) { select(); if (checkable) { + if (!checked && Object::cast_to(object) && property_path.begins_with("theme_override_")) { + List pinfo; + object->get_property_list(&pinfo); + for (const PropertyInfo &E : pinfo) { + if (E.type == Variant::OBJECT && E.name == property_path) { + EditorToaster::get_singleton()->popup_str(TTR("Toggling the checkbox is disabled for Resource properties. Modify the property using the resource picker instead."), EditorToaster::SEVERITY_WARNING); + return; + } + } + } + checked = !checked; queue_redraw(); emit_signal(SNAME("property_checked"), property, checked); @@ -5155,17 +5177,9 @@ void EditorInspector::_property_checked(const String &p_path, bool p_checked) { } else { Variant to_create; Control *control = Object::cast_to(object); - bool skip = false; if (control && p_path.begins_with("theme_override_")) { to_create = control->get_used_theme_item(p_path); - Ref resource = to_create; - if (resource.is_valid()) { - to_create = resource->duplicate(); - } - skip = true; - } - - if (!skip) { + } else { List pinfo; object->get_property_list(&pinfo); for (const PropertyInfo &E : pinfo) {