You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Support opening a custom context menu when right-clicking a draggable region of the app under Windows #24893
Under Windows regions of the app that have -webkit-app-region: drag applied to them come also with a special context menu that can't be overridden.
Proposed Solution
I think it might be best to not show that default context menu at all, as it makes it impossible to provide a custom one. Also for whatever reason that context menu under Windows doesn't even look like the regular ones, I think it would be better to be able to provide users with consistent context menus.
Alternatives Considered
Reimplementing -webkit-app-region: drag? That'd be a bit crazy, if it's even possible to do at the app level.
Technically draggable regions work on Windows by marking the area as titlebar, so in theory we can support custom menu by support setting menu for titlebar. I don't think anyone in the team would be interested in implementing this, but I'm leaving this issue open.
It's now possible to prevent the system menu from appearing and display your own Menu in its place. This is thanks to the system-context-menu event added to the BrowserWindow in #25795
@samuelmaddock is that working for you? Last time I tried it wasn't working for me 🤔
Ah, looks like there's a known bug #26726. I was able to get the system-context-menu event to appear only when right-clicking on a framed window's title bar.
Activity
zcbenz commentedon Aug 17, 2020
Technically draggable regions work on Windows by marking the area as titlebar, so in theory we can support custom menu by support setting menu for titlebar. I don't think anyone in the team would be interested in implementing this, but I'm leaving this issue open.
Kenhuey commentedon Oct 18, 2020
I think this is a great enhancement, sometimes we need to drag window, but cannot disable the right-click menu. I am sad :(
samuelmaddock commentedon Jan 27, 2021
It's now possible to prevent the system menu from appearing and display your own
Menuin its place. This is thanks to thesystem-context-menuevent added to the BrowserWindow in #25795fabiospampinato commentedon Jan 27, 2021
@samuelmaddock is that working for you? Last time I tried it wasn't working for me 🤔
samuelmaddock commentedon Jan 28, 2021
Ah, looks like there's a known bug #26726. I was able to get the
system-context-menuevent to appear only when right-clicking on a framed window's title bar.qjl1569 commentedon Apr 26, 2022
// https://docs.microsoft.com/en-us/windows/win32/menurc/wm-initmenu?redirectedfrom=MSDN
const WM_INITMENU = 0x0116;
const menu = Menu.buildFromTemplate([
{
label: "Test",
},
{
label: "Test",
}
]);
win.hookWindowMessage(WM_INITMENU, () => {
win.setEnabled(false);
win.setEnabled(true);
menu.popup();
});
whzard commentedon Apr 27, 2022
@qjl1569 your solution works, thank you!