Repository: godotengine/godot
File: editor/inspector/editor_inspector.cpp (C++)

Code before:

void EditorInspectorCategory::_handle_menu_option(int p_option) {
	switch (p_option) {
		case MENU_COPY_VALUE: {
			Object *object = EditorInterface::get_singleton()->get_inspector()->get_edited_object();
			Dictionary clipboard;
			Vector<String> properties;
			_collect_properties(object, properties);

			clipboard["path"] = doc_class_name;
			for (String property_name : properties) {
				clipboard[property_name] = object->get(property_name);
			}
			InspectorDock::get_inspector_singleton()->set_property_clipboard(clipboard);
		} break;

		case MENU_PASTE_VALUE: {
			Object *object = EditorInterface::get_singleton()->get_inspector()->get_edited_object();
			Dictionary clipboard = InspectorDock::get_inspector_singleton()->get_property_clipboard();
			String category_name = clipboard["path"];

			if (category_name != doc_class_name) {
				break;
			}

			String action_name = "Set category " + category_name;

			EditorUndoRedoManager *undo_redo = EditorUndoRedoManager::get_singleton();
			undo_redo->create_action(action_name);

			for (String property_name : clipboard.keys()) {
				Variant value = clipboard[property_name];
				undo_redo->add_do_property(object, property_name, value);
				undo_redo->add_undo_property(object, property_name, object->get(property_name));
			}

			undo_redo->commit_action();
		} break;

		case MENU_OPEN_DOCS: {
			ScriptEditor::get_singleton()->goto_help("class:" + doc_class_name);
			EditorNode::get_singleton()->get_editor_main_screen()->select(EditorMainScreen::EDITOR_SCRIPT);
		} break;

		case MENU_UNFAVORITE_ALL: {
			emit_signal(SNAME("unfavorite_all"));
		} break;
	}
}

void EditorInspectorCategory::_popup_context_menu(const Point2i &p_position) {

Review comment (suggestion):
```suggestion
			String action_name = vformat(TTR("Set category %s"), category_name);
```

Code after:
			// Use TextLine so we have access to accurate font metrics. This way,
			// we can ensure the line is vertically centered regardless of the font used
			// or its size.
			Ref<TextLine> tl;
			tl.instantiate();
			tl->add_string(label, font, font_size);
			tl->set_width(w);
			tl->set_horizontal_alignment(HORIZONTAL_ALIGNMENT_LEFT);
			float text_pos_y = (get_size().height - tl->get_size().height) / 2 + v_margin_offset;
			Point2 text_pos = Point2(ofs, text_pos_y).round();
			tl->draw(get_canvas_item(), text_pos, theme_cache.font_color);
		} break;
	}
}

void EditorInspectorCategory::_accessibility_action_menu(const Variant &p_data) {
	_popup_context_menu(get_screen_position());
}

Control *EditorInspectorCategory::make_custom_tooltip(const String &p_text) const {
	// If it's not a doc tooltip, fallback to the default one.
	if (doc_class_name.is_empty()) {
		return nullptr;
	}

	return EditorHelpBitTooltip::make_tooltip(const_cast<EditorInspectorCategory *>(this), p_text);
}

void EditorInspectorCategory::set_as_favorite() {
	is_favorite = true;
	_update_icon();
}

void EditorInspectorCategory::set_property_info(const PropertyInfo &p_info) {
	info = p_info;

	Ref<Script> scr = _get_category_script(info);
	if (scr.is_valid()) {
		StringName script_name = EditorNode::get_editor_data().script_class_get_name(scr->get_path());
		if (script_name != StringName()) {
			label = script_name;
		}
	}
	if (label.is_empty()) {
		label = info.name;
	}
	_update_icon();
}

void EditorInspectorCategory::set_doc_class_name(const String &p_name) {
	doc_class_name = p_name;