Skip to content

Commit 124e398

Browse files
committed
Add support for context menu checkbox & radio buttons
1 parent 28900af commit 124e398

File tree

1 file changed

+10
-2
lines changed

1 file changed

+10
-2
lines changed

src/context-menu.ts

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,11 @@ interface ContextMenuOption {
1717
label: string;
1818
enabled?: boolean;
1919
accelerator?: string;
20+
optionType?:
21+
| 'checkbox'
22+
| 'radio'
23+
| 'normal';
24+
checked?: boolean; // only for checkbox/radio type
2025
}
2126

2227
interface ContextMenuSubmenu {
@@ -63,12 +68,15 @@ function buildContextMenuItem(item: ContextMenuItem, callback: ContextMenuCallba
6368

6469
function buildContextMenuOption(option: ContextMenuOption, callback: ContextMenuCallback) {
6570
return new Electron.MenuItem({
66-
type: 'normal',
71+
type: option.optionType || 'normal',
6772
id: option.id,
6873
label: option.label,
6974
enabled: option.enabled,
7075
click: callback,
71-
accelerator: option.accelerator
76+
accelerator: option.accelerator,
77+
checked: (option.optionType === 'checkbox' || option.optionType === 'radio')
78+
? !!option.checked
79+
: undefined
7280
});
7381
}
7482

0 commit comments

Comments
 (0)