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
system-context-menu prevents the default behavior from being invalid #26726
The Electron code that delegates to NativeWindowObserver looks fine, but for some reason NativeWindowViews::PreHandleMSG isn't getting any WM_CONTEXTMENU messages, so that event handler + delegation code is never being reached
frame: false is a prerequisite for triggering this bug.
Electron never sees the WM_CONTEXTMENU message because hwnd_message_handler.cc uses its own custom event handling for WM_RBUTTONUP here. The invocation of SendMessage() in that paragraph returns HTCAPTION, so ShowSystemMenuAtScreenPixelLocation() is called.
That block of code is reached in the first place because is_right_mouse_pressed_on_caption_ is set to true here.
frame false system-context-menu is not triggered in 12.0.0, either, when right clicking on the draggable region, opposed to the documentation on the pull request for the feature.
I cannot speak for any other configurations at this time.
This setting masks the system menu, but the custom right-click menu is also masked. Is there a way to block only Windows system menu operations because I want to customize the right-click menu
@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.
frame: false is a prerequisite for triggering this bug.
Electron never sees the WM_CONTEXTMENU message because hwnd_message_handler.cc uses its own custom event handling for WM_RBUTTONUP here. The invocation of SendMessage() in that paragraph returns HTCAPTION, so ShowSystemMenuAtScreenPixelLocation() is called.
That block of code is reached in the first place because is_right_mouse_pressed_on_caption_ is set to true here.
Can't the NativeWindowViews::PreHandleMSG be used to intercept this behaviour for WM_RBUTTONUP message and check if the current view is frameless and considering that as a system context menu message? This comment seems to indicate this method is called before HWNDMessageHandler to handle messages when possible.
// Catch-all message handling and filtering. Called before
// HWNDMessageHandler's built-in handling, which may pre-empt some
// expectations in Views/Aura if messages are consumed. Returns true if the
// message was consumed by the delegate and should not be processed further
// by the HWNDMessageHandler. In this case, |result| is returned. |result| is
// not modified otherwise.
I don't have access to any Windows machine to test this on, but I would appreciate if someone who can build Electron on Windows can add this switch case inside NativeWindowViews::PreHandleMSG and try checking if you can console.log inside the system-context-menu event.
Activity
MarshallOfSound commentedon Nov 29, 2020
Can you provide complete repro steps, the current steps won't open that menu so it's unclear how you're opening it.
Linkontoask commentedon Nov 29, 2020
Reproduce the warehouse
https://github.com/Linkontoask/electron-system-context-menu
Step
https://github.com/Linkontoask/electron-system-context-menu/blob/42499c80dc183c33642ec9c68a65691a18e5dcce/index.js#L16
ckerr commentedon Nov 29, 2020
Gist copy @ https://gist.github.com/ckerr/3116ae2362ef785c99e6909579f9e07e
ckerr commentedon Nov 29, 2020
The Electron code that delegates to NativeWindowObserver looks fine, but for some reason NativeWindowViews::PreHandleMSG isn't getting any WM_CONTEXTMENU messages, so that event handler + delegation code is never being reached
ckerr commentedon Nov 29, 2020
frame: falseis a prerequisite for triggering this bug.Electron never sees the WM_CONTEXTMENU message because hwnd_message_handler.cc uses its own custom event handling for WM_RBUTTONUP here. The invocation of SendMessage() in that paragraph returns HTCAPTION, so ShowSystemMenuAtScreenPixelLocation() is called.
That block of code is reached in the first place because is_right_mouse_pressed_on_caption_ is set to true here.
fabiospampinato commentedon Dec 7, 2020
The "system-context-menu" event is never triggered for me under Electron 11.0.3 and Windows 10, I'm using
frame: false.ericblade commentedon Mar 3, 2021
frame false system-context-menu is not triggered in 12.0.0, either, when right clicking on the draggable region, opposed to the documentation on the pull request for the feature.
I cannot speak for any other configurations at this time.
15 remaining items
fabiospampinato commentedon Jan 10, 2023
Still interested in this
ferreira-tb commentedon Mar 17, 2023
Still persists in 23.1.4 when
frame: false.stalker8610 commentedon Apr 19, 2023
Still interested in this
endlesszorn commentedon Jun 28, 2023
This setting masks the system menu, but the custom right-click menu is also masked. Is there a way to block only Windows system menu operations because I want to customize the right-click menu
whzard commentedon Jun 28, 2023
@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.endlesszorn commentedon Jun 28, 2023
Thank you for your help, I have completed the effect I want, thank you!
aronCiucu commentedon Sep 8, 2023
Bump
pagoru commentedon Sep 16, 2023
Fix this
thisisrandomguys commentedon Nov 13, 2023
Bump
boiboif commentedon Dec 27, 2023
Bump
eXhumer commentedon Apr 16, 2024
Can't the
NativeWindowViews::PreHandleMSGbe used to intercept this behaviour forWM_RBUTTONUPmessage and check if the current view is frameless and considering that as a system context menu message? This comment seems to indicate this method is called before HWNDMessageHandler to handle messages when possible.electron/shell/browser/native_window_views.h
Lines 153 to 158 in c670e38
I don't have access to any Windows machine to test this on, but I would appreciate if someone who can build Electron on Windows can add this switch case inside
NativeWindowViews::PreHandleMSGand try checking if you canconsole.loginside thesystem-context-menuevent.xXTurnerLP commentedon Jul 6, 2024
v31.1.0
i have the issue as well