File tree Expand file tree Collapse file tree 1 file changed +10
-2
lines changed Expand file tree Collapse file tree 1 file changed +10
-2
lines changed Original file line number Diff line number Diff line change @@ -17,6 +17,11 @@ interface ContextMenuOption {
17
17
label : string ;
18
18
enabled ?: boolean ;
19
19
accelerator ?: string ;
20
+ optionType ?:
21
+ | 'checkbox'
22
+ | 'radio'
23
+ | 'normal' ;
24
+ checked ?: boolean ; // only for checkbox/radio type
20
25
}
21
26
22
27
interface ContextMenuSubmenu {
@@ -63,12 +68,15 @@ function buildContextMenuItem(item: ContextMenuItem, callback: ContextMenuCallba
63
68
64
69
function buildContextMenuOption ( option : ContextMenuOption , callback : ContextMenuCallback ) {
65
70
return new Electron . MenuItem ( {
66
- type : 'normal' ,
71
+ type : option . optionType || 'normal' ,
67
72
id : option . id ,
68
73
label : option . label ,
69
74
enabled : option . enabled ,
70
75
click : callback ,
71
- accelerator : option . accelerator
76
+ accelerator : option . accelerator ,
77
+ checked : ( option . optionType === 'checkbox' || option . optionType === 'radio' )
78
+ ? ! ! option . checked
79
+ : undefined
72
80
} ) ;
73
81
}
74
82
You can’t perform that action at this time.
0 commit comments