electron: system-context-menu prevents the default behavior from being invalid
Preflight Checklist
- I have read the Contributing Guidelines for this project.
- I agree to follow the Code of Conduct that this project adheres to.
- I have searched the issue tracker for an issue that matches the one I want to file, without success.
Issue Details
- Electron Version:
- 11.0.3
- Operating System:
- Windows 10 (1803)
- Last Known Working Electron version:
Expected Behavior
Prevent the default menu context from being displayed
Actual Behavior

To Reproduce
- Set frame to true
- Set
-webkit-app-region: drag - Finally write the following code
win.on('system-context-menu', e => {
e.preventDefault()
})
Screenshots

Additional Information
About this issue
- Original URL
- State: open
- Created 4 years ago
- Comments: 30 (11 by maintainers)
Commits related to this issue
- fix: impede o surgimento do menu de contexto do sistema — committed to ferreira-tb/ares by ferreira-tb a year ago
- fix: Override default system context menu for draggable frameless windows in Windows (https://github.com/electron/electron/issues/24893) * system-context-menu event is never fired with frameless wind... — committed to eXhumer/eXViewer by eXhumer 3 months ago
any fix ?
and i find a sideway , it works for me (just works and i didn’t know why )
refers:
https://github.com/electron/electron/issues/24893#issuecomment-1109262719Still interested in this
I think a proper solution to this should still be provided.
The “system-context-menu” event is never triggered for me under Electron 11.0.3 and Windows 10, I’m using
frame: false.“system-context-menu” is still broken for me under Electron v12, it’s just not triggered.
Using Electron 16.0.4. This issue still persists. With
frame: falsethesystem-context-menuevent is not triggered.Thank you for your help, I have completed the effect I want, thank you!
@yangsen9608, you’re supposed to add the custom menu popup code inside the event handler, after the
win.setEnabled(true);line. This works for me on the latest Electron version.