Skip to content

Workspace.on('file-menu') method

Workspace › on(‘file-menu’)

Official

Triggered when the user opens the context menu on a file.

Signature:

on(name: "file-menu", callback: (menu: Menu, file: TAbstractFile, source: string, leaf?: WorkspaceLeaf | undefined) => unknown, ctx?: unknown): EventRef

Parameters:

ParameterTypeDescription
name"file-menu"Should be 'file-menu'.
callback(menu: Menu, file: TAbstractFile, source: string, leaf?: WorkspaceLeaf | undefined) => unknownThe callback function.
ctx?unknownThe context passed as this to the callback function.

Returns: EventRefThe event reference.

Example:

app.workspace.on('file-menu', (menu, file, source, leaf) => {
console.log(menu, file, source, leaf);
});