Home > SYS_RightClickMenu > changeMenu
SYS_RightClickMenu.changeMenu() method
此 API 当前处于 BETA 预览状态,希望得到开发者的反馈。它的任何功能都可能在接下来的开发进程中被修改,请不要将它用于任何正式环境。
修改右键菜单
签名
typescript
function changeMenu(
menuId: string,
menuItems: Array<ISYS_RightClickMenuItem | null>,
): Promise<void>;1
2
3
4
2
3
4
参数名
参数 | 类型 | 描述 |
|---|---|---|
menuId | string | 菜单 ID |
menuItems | Array<ISYS_RightClickMenuItem | null> | 菜单项, |
返回值
Promise<void>
备注
当前仅支持 **底部菜单器件列表项目右击**、**底部菜单符号列表项目右击**、**底部菜单封装列表项目右击**、**底部菜单复用模块列表项目右击** 的右键菜单修改
如若希望重新排序、移除部分菜单项,在 menuItems 内只需传入菜单项 ID,其它属性将自动保持不变
如若需要注册新的右键菜单,需要传入完整的 ISYS_RightClickMenuItem 数据
本接口将会强制新建的右键菜单的 ID 包含扩展 UUID,例如输入的 id = 'example',将会被自动重写为 e143d88179874e7f851cc890cd22fc71|example
注意:本接口需要使用者启用扩展的外部交互权限,如若未启用将始终 throw Error
非公开接口使用提醒:本接口按原样提供,不提供参数的额外文档,参数可能在任何版本出现破坏性更改并不另行通知
示例
javascript
// 1. 打开底部库面板,便于右击列表项观察菜单变化
eda.sys_PanelControl.openBottomPanel('library');
// 2. 组合新的菜单项列表:内置项只传 id(保持原属性、原图标与快捷键),
// 末尾追加扩展自定义菜单项(完整数据,含二级菜单与点击回调)
const menuItems = [
{ id: 'refresh' },
null,
{ id: 'editDevice' },
{ id: 'easyEditDevice' },
{ id: 'editSymbol' },
{ id: 'linkSymbol' },
{ id: 'editFootprint' },
{ id: 'linkFootprint' },
{ id: 'link3DModel' },
null,
{ id: 'modifyCategory' },
null,
{ id: 'libDelete' },
null,
{ id: 'saveAs' },
{ id: 'symbolSaveAs' },
{ id: 'footprintSaveAs' },
{ id: 'saveAsLocal' },
{ id: 'model3DSaveAs' },
null,
{ id: 'viewProductDetail' },
{ id: 'viewDatasheet' },
null,
{ id: 'addOrRemoveFavorite' },
{ id: 'addIntoBasicLibrary' },
null,
{
id: '嘉立创示例_器件批量处理',
title: '器件批量处理',
menuItems: [
{ id: '嘉立创示例_发送校验', title: '发送校验', registerFn: 'onDeviceCheck' },
{ id: '嘉立创示例_导出BOM', title: '导出 BOM', registerFn: 'onDeviceExport' },
],
},
];
// 3. 注册到个人器件列表的右键菜单(真实扩展在入口文件导出
// onDeviceCheck / onDeviceExport 两个方法即可收到点击回调)
await eda.sys_RightClickMenu.changeMenu('componentLidTableContextMenuIdMenu_device_personal', menuItems);
// 4. 输出结果:在底部库面板右击个人器件列表的任意器件即可看到新菜单
console.log('右键菜单已修改,菜单项数量:', menuItems.length);
console.log('请在底部库面板右击个人器件列表的器件查看效果');1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49