fix: EditorContextMenuPlugin CONTEXT_SLOT_FILESYSTEM_CREATE does not receive path information for some menu

Also add explanation in `EditorContextMenuPlugin`'s doc for fixing path information passing

(Accept PR #106820 suggestion by: Tomasz Chabora <kobewi4e@gmail.com>)
This commit is contained in:
Ozelot Vanilla
2025-06-02 15:37:12 +09:00
parent 64b09905c7
commit 94669955d8
2 changed files with 7 additions and 2 deletions

View File

@@ -2613,7 +2613,12 @@ void FileSystemDock::_file_option(int p_option, const Vector<String> &p_selected
default: {
if (p_option >= EditorContextMenuPlugin::BASE_ID) {
if (!EditorContextMenuPluginManager::get_singleton()->activate_custom_option(EditorContextMenuPlugin::CONTEXT_SLOT_FILESYSTEM, p_option, p_selected)) {
EditorContextMenuPluginManager::get_singleton()->activate_custom_option(EditorContextMenuPlugin::CONTEXT_SLOT_FILESYSTEM_CREATE, p_option, p_selected);
// For create new file option, pass the path location of mouse click position instead, to plugin callback.
String fpath = current_path;
if (!fpath.ends_with("/")) {
fpath = fpath.get_base_dir();
}
EditorContextMenuPluginManager::get_singleton()->activate_custom_option(EditorContextMenuPlugin::CONTEXT_SLOT_FILESYSTEM_CREATE, p_option, { fpath });
}
} else if (p_option >= CONVERT_BASE_ID) {
selected_conversion_id = p_option - CONVERT_BASE_ID;