Skip to content

Commit 39141e7

Browse files
committed
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).
1 parent a3b42d8 commit 39141e7

File tree

1 file changed

+23
-9
lines changed

1 file changed

+23
-9
lines changed

editor/inspector/editor_inspector.cpp

Lines changed: 23 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@
3939
#include "editor/editor_node.h"
4040
#include "editor/editor_string_names.h"
4141
#include "editor/editor_undo_redo_manager.h"
42+
#include "editor/gui/editor_toaster.h"
4243
#include "editor/gui/editor_validation_panel.h"
4344
#include "editor/inspector/add_metadata_dialog.h"
4445
#include "editor/inspector/editor_properties.h"
@@ -1062,6 +1063,16 @@ void EditorProperty::gui_input(const Ref<InputEvent> &p_event) {
10621063

10631064
if (check_rect.has_point(mpos)) {
10641065
accept_event();
1066+
if (!checked && Object::cast_to<Control>(object) && property_path.begins_with("theme_override_")) {
1067+
List<PropertyInfo> pinfo;
1068+
object->get_property_list(&pinfo);
1069+
for (const PropertyInfo &E : pinfo) {
1070+
if (E.type == Variant::OBJECT && E.name == property_path) {
1071+
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);
1072+
return; // Disallow clicking to toggle the checkbox of type Resource to checked.
1073+
}
1074+
}
1075+
}
10651076
checked = !checked;
10661077
queue_redraw();
10671078
emit_signal(SNAME("property_checked"), property, checked);
@@ -1080,6 +1091,17 @@ void EditorProperty::gui_input(const Ref<InputEvent> &p_event) {
10801091
void EditorProperty::_accessibility_action_click(const Variant &p_data) {
10811092
select();
10821093
if (checkable) {
1094+
if (!checked && Object::cast_to<Control>(object) && property_path.begins_with("theme_override_")) {
1095+
List<PropertyInfo> pinfo;
1096+
object->get_property_list(&pinfo);
1097+
for (const PropertyInfo &E : pinfo) {
1098+
if (E.type == Variant::OBJECT && E.name == property_path) {
1099+
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);
1100+
return;
1101+
}
1102+
}
1103+
}
1104+
10831105
checked = !checked;
10841106
queue_redraw();
10851107
emit_signal(SNAME("property_checked"), property, checked);
@@ -5155,17 +5177,9 @@ void EditorInspector::_property_checked(const String &p_path, bool p_checked) {
51555177
} else {
51565178
Variant to_create;
51575179
Control *control = Object::cast_to<Control>(object);
5158-
bool skip = false;
51595180
if (control && p_path.begins_with("theme_override_")) {
51605181
to_create = control->get_used_theme_item(p_path);
5161-
Ref<Resource> resource = to_create;
5162-
if (resource.is_valid()) {
5163-
to_create = resource->duplicate();
5164-
}
5165-
skip = true;
5166-
}
5167-
5168-
if (!skip) {
5182+
} else {
51695183
List<PropertyInfo> pinfo;
51705184
object->get_property_list(&pinfo);
51715185
for (const PropertyInfo &E : pinfo) {

0 commit comments

Comments
 (0)