# How do I add a contextmenu to my view?
#obsidian/api/faq
---
## File-aware context menu
If you are adding a context menu to your View, you can trigger the `file-menu` event on
the [[Workspace]].
Triggering `file-menu` means that all the plugins listening for the `file-menu` event have an
opportunity to append `MenuItem`s to the list before it gets shown with `.showAtPosition()`. By default, this adds file-aware items such as "copy url", "reveal in file explorer." However, other plugins can also listen for the event and add their own entries.
### Sample Code
```ts
const fileMenu = new Menu(); // Creates empty file menu
// hook for plugins to populate menu with "file-aware" menu items
this.app.workspace.trigger(
"file-menu",
fileMenu,
file,
"my-context-menu",
null
);
fileMenu.showAtPosition({ x: event.pageX, y: event.pageY }); // Actually open the menu
```
## Completely custom contextmenu
If you don't want those entries in your context menu, just don't trigger the `file-menu` event and instead add your own `MenuItem`s.
### Sample Code
```ts
const myMenu = new Menu();
myMenu.addItem((item) =>
item
.setTitle("My Custom Action")
.setIcon("trash")
.onClick(() => {
myCustomFunction();
})
);
```