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()
112112 new MenuItem { Label = "Electron.NET" , Type = MenuType . checkbox , Checked = true }
113113 } ;
114114
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+ } ;
119119
120120 Electron . IpcMain . On ( "show-context-menu" , ( args ) =>
121121 {
122+ var mainWindow = Electron . WindowManager . BrowserWindows . FirstOrDefault ( ) ;
122123 Electron . Menu . ContextMenuPopup ( mainWindow ) ;
123124 } ) ;
124125 }
You can’t perform that action at this time.
0 commit comments