Context menu event when multiple files are selected

When a file or folder in the Files pane is right clicked, a context menu appears. This event can be captured by using registerEvent(this.app.workspace.on("file-menu", delegate)).

image-1

What I want to achieve is to add a menu item to the context menu whenever multiple items in the Files pane are selected using Alt+Click and the user right clicks. Currently, only two items are visible for me in this menu, “Move x items to…” and “Delete”.

image-2

Unfortunately the file-menu event is not triggered in this scenario and I could not find anything related to this in the documentation. How can I capture this event, and the related information such as which files/folders were selected when the user right clicked?

Phew, I did a deep dive into this today for a plugin I was working on. In case you were still puzzling over this, there’s a files-menu event that triggers when right-clicking multiple files (as of Obsidian v1.3.5, at least). Just replace the name of the event and that should get you what you need!

registerEvent(this.app.workspace.on("files-menu", delegate))

How did you find this “files-menu” event? I don’t see it in the plugin API. Is there other source you can find it in?

Unfortunately, no. I found this in the developer console for Obsidian by digging through app.js in the Sources tab. That was after a very lengthy and fruitless search for online discussion or documentation.

Wow, good find!