File tree Expand file tree Collapse file tree 1 file changed +5
-4
lines changed
ElectronNET-API-Demos/Controllers Expand file tree Collapse file tree 1 file changed +5
-4
lines changed Original file line number Diff line number Diff line change @@ -112,13 +112,14 @@ private void CreateContextMenu()
112
112
new MenuItem { Label = "Electron.NET" , Type = MenuType . checkbox , Checked = true }
113
113
} ;
114
114
115
- var mainWindow = Electron . WindowManager . BrowserWindows . FirstOrDefault ( ) ;
116
- if ( mainWindow == null ) return ;
117
-
118
- Electron . Menu . SetContextMenu ( mainWindow , menu ) ;
115
+ Electron . App . BrowserWindowFocus += ( ) => {
116
+ var mainWindow = Electron . WindowManager . BrowserWindows . FirstOrDefault ( ) ;
117
+ Electron . Menu . SetContextMenu ( mainWindow , menu ) ;
118
+ } ;
119
119
120
120
Electron . IpcMain . On ( "show-context-menu" , ( args ) =>
121
121
{
122
+ var mainWindow = Electron . WindowManager . BrowserWindows . FirstOrDefault ( ) ;
122
123
Electron . Menu . ContextMenuPopup ( mainWindow ) ;
123
124
} ) ;
124
125
}
You can’t perform that action at this time.
0 commit comments