# contextMenu（右鍵選單）

## 方法 <a href="#z1a5y" id="z1a5y"></a>

## open(menuItems) <a href="#tkp0d" id="tkp0d"></a>

彈出右鍵選單。

* `menuItems` : [MenuItem](https://www.electronjs.org/docs/latest/api/menu-item)
  * `id` string - 選單項目 ID
  * `label` string - 選單項目顯示的文字
  * `submenu` \[MenuItem] - 子選單

```javascript
eagle.contextMenu.open([
    {
        id: "edit",
        label: "編輯",
        submenu: [
            {
                id: "resize",
                label: "調整大小",
                click: () => { alert("圖片已調整大小") }
            },
            {
                id: "crop",
                label: "裁剪",
                click: () => { alert("圖片已裁剪") }
            },
            {
                id: "rotate",
                label: "旋轉",
                click: () => { alert("圖片已旋轉") }
            }
        ]
    },
    {
        id: "effects",
        label: "效果",
        submenu: [
            {
                id: "grayscale",
                label: "灰階",
                click: () => { alert("已應用灰階效果") }
            },
            {
                id: "sepia",
                label: "懷舊色",
                click: () => { alert("已應用懷舊色效果") }
            },
            {
                id: "invert",
                label: "顏色反轉",
                click: () => { alert("已應用顏色反轉") }
            }
        ]
    },
    {
        id: "export",
        label: "匯出",
        click: () => { alert("圖片已匯出") }
    }
])
```


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://developer.eagle.cool/plugin-api/zh-tw/api/context-menu.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
