ContextMenu does not appear to work #450

Open
opened 2026-01-29 16:39:56 +00:00 by claunia · 0 comments
Owner

Originally created by @robalexclark on GitHub (Feb 9, 2020).

Originally assigned to: @GregorBiswanger on GitHub.

I'm probably missing something here, but I can't get the context menu to appear. I checked in the demo code and updated it as follows to add a Copy function:

 public async void ElectronBootstrap()
        {
            var browserWindow = await Electron.WindowManager.CreateWindowAsync(new BrowserWindowOptions
            {
                Width = 1152,
                Height = 940,
                Show = false
            });

            await browserWindow.WebContents.Session.ClearCacheAsync();

            MenuItem[] contextMenu = new MenuItem[] {
                new MenuItem { Label = "Copy", Accelerator = "CmdOrCtrl+C", Role = MenuRole.copy }
            };

            Electron.Menu.SetContextMenu(browserWindow, contextMenu);

            browserWindow.OnReadyToShow += () => browserWindow.Show();
            browserWindow.SetTitle(Configuration["DemoTitleInSettings"]);
        }

However, right clicking on the window does not make the context menu appear - why not?

Originally created by @robalexclark on GitHub (Feb 9, 2020). Originally assigned to: @GregorBiswanger on GitHub. I'm probably missing something here, but I can't get the context menu to appear. I checked in the demo code and updated it as follows to add a Copy function: ``` public async void ElectronBootstrap() { var browserWindow = await Electron.WindowManager.CreateWindowAsync(new BrowserWindowOptions { Width = 1152, Height = 940, Show = false }); await browserWindow.WebContents.Session.ClearCacheAsync(); MenuItem[] contextMenu = new MenuItem[] { new MenuItem { Label = "Copy", Accelerator = "CmdOrCtrl+C", Role = MenuRole.copy } }; Electron.Menu.SetContextMenu(browserWindow, contextMenu); browserWindow.OnReadyToShow += () => browserWindow.Show(); browserWindow.SetTitle(Configuration["DemoTitleInSettings"]); } ``` However, right clicking on the window does not make the context menu appear - why not?
claunia added the bug label 2026-01-29 16:39:56 +00:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/Electron.NET#450