Repository navigation
Redispatch events to handle native OSX shortcuts - #6068
Conversation
|
@zcbenz do you think it makes more sense to try and use the Chromium classes directly here like |
| } | ||
| } | ||
| if (event.os_event.window) { | ||
| AtomNSWindow* native_window = static_cast<AtomNSWindow*>(event.os_event.window); |
There was a problem hiding this comment.
For undocked devtools window, it is not an AtomNSWindow, we might need to add same code in brightray.
Also I haven't tried, but I think we should be able to just call [window redispatchKeyEvent:] without type conversion.
There was a problem hiding this comment.
Also I haven't tried, but I think we should be able to just call [window redispatchKeyEvent:] without type conversion.
Yeah, when I try that I get the following compiler error:
error: 'NSWindow' may not respond to 'redispatchKeyEvent:' [-Werror]
I think current implementation is perfect. |
fb5d9b6 to
73d9550
Compare
| } | ||
| } | ||
| NSWindow* window = event.os_event.window; | ||
| if (window && [window isKindOfClass:[AtomNSWindow class]]) { |
There was a problem hiding this comment.
@zcbenz Switched it to use isKindOfClass instead.
There was a problem hiding this comment.
@kevinsawicki The devtools window also needs the same handling code, otherwise it won't respond to cmd+~, steps to reproduce:
- Open devtools window in detached state
- Press
cmd+~in it
There was a problem hiding this comment.
Oh, yeah, didn't realize that, thanks 👍
There was a problem hiding this comment.
@zcbenz I opened up a small brightray pull request that applies the minimal event redispatch to the UnderlayOpenGLHostingWindow used there for the devtools window.
Does that approach make sense?
95fdd42 to
e0f06d5
Compare
|
@zcbenz I reworked this pull request to add an
This seems okay since Let me know if you have concerns with this approach. |
b891cc4 to
0e65977
Compare
a0ae494 to
13e554a
Compare
This pull request pulls in code from command_dispatcher.mm that redispatches events in an attempt to correctly handle native keyboard shortcuts like
Ctrl+F2andCmd-~on Mac OS X.Tested Scenarios
Cmd-R,Cmd-A,Cmd-Alt-I.Cmd-~andCtrl-F2preventDefault()on akeydownevent to disable something native likeCmd-Ato select all<input>elementsIf anyone is able to test this branch for their app and verify menus and shortcuts still work as expected, that would be really helpful. /cc @electron/maintainers
Closes #5246
Closes #6016
Depends on electron-archive/brightray#227
Related reading:
https://www.chromium.org/developers/os-x-keyboard-handling
nwjs/nw.js@6658fbb