mirror of
https://github.com/wavetermdev/waveterm
synced 2026-05-06 06:58:21 +00:00
Checkbox and Radio Context Menu Items (#861)
Expands the context menu to allow checkbox and radio button items.
This commit is contained in:
parent
3da79f80f4
commit
de92e53c38
3 changed files with 6 additions and 2 deletions
|
|
@ -750,6 +750,7 @@ function convertMenuDefArrToMenu(menuDefArr: ElectronContextMenuItem[]): electro
|
|||
click: (_, window) => {
|
||||
(window as electron.BrowserWindow)?.webContents?.send("contextmenu-click", menuDef.id);
|
||||
},
|
||||
checked: menuDef.checked,
|
||||
};
|
||||
if (menuDef.submenu != null) {
|
||||
menuItemTemplate.submenu = convertMenuDefArrToMenu(menuDef.submenu);
|
||||
|
|
|
|||
|
|
@ -25,6 +25,7 @@ class ContextMenuModelType {
|
|||
type: item.type,
|
||||
label: item.label,
|
||||
id: crypto.randomUUID(),
|
||||
checked: item.checked,
|
||||
};
|
||||
if (item.click) {
|
||||
this.handlers.set(electronItem.id, item.click);
|
||||
|
|
|
|||
6
frontend/types/custom.d.ts
vendored
6
frontend/types/custom.d.ts
vendored
|
|
@ -81,16 +81,18 @@ declare global {
|
|||
id: string; // unique id, used for communication
|
||||
label: string;
|
||||
role?: string; // electron role (optional)
|
||||
type?: "separator" | "normal" | "submenu";
|
||||
type?: "separator" | "normal" | "submenu" | "checkbox" | "radio";
|
||||
submenu?: ElectronContextMenuItem[];
|
||||
checked?: boolean;
|
||||
};
|
||||
|
||||
type ContextMenuItem = {
|
||||
label?: string;
|
||||
type?: "separator" | "normal" | "submenu";
|
||||
type?: "separator" | "normal" | "submenu" | "checkbox" | "radio";
|
||||
role?: string; // electron role (optional)
|
||||
click?: () => void; // not required if role is set
|
||||
submenu?: ContextMenuItem[];
|
||||
checked?: boolean;
|
||||
};
|
||||
|
||||
type KeyPressDecl = {
|
||||
|
|
|
|||
Loading…
Reference in a new issue