# dp-context-menu
A custom right-click (and long-press on touch) context menu. A single instance is created by
`Application.js` and reachable as `app.contextMenu`.
Source: `static/js/components/AppContextMenu.js`.
## Methods
| Method | Description |
|---|---|
| `attach(host, builder)` | Bind to an element. `builder(event)` returns the item array to show, or an empty array to suppress. Handles desktop right-click and a 500ms touch long-press. |
| `open(x, y, items)` | Open the menu at viewport coordinates with the given items. |
| `close()` | Hide the menu. |
Each item: `{ label, onSelect, icon?, danger?, disabled?, separator? }`. Use `{ separator: true }`
for a divider. The menu repositions to stay within the viewport and auto-closes on selection,
outside click, scroll, resize, or Escape.
## Usage
```html
<dp-context-menu></dp-context-menu>
```
```javascript
app.contextMenu.attach(myElement, (event) => [
{ label: "Open", onSelect: () => open() },
{ separator: true },
{ label: "Delete", danger: true, onSelect: () => remove() },
]);
```
Live example - right-click (or long-press) the box