mirror of
https://github.com/Foundry376/Mailspring.git
synced 2025-01-01 13:14:16 +08:00
fix(keymaps): Small tweaks to fix broken key behaviors
- Reload the menu after changing keymap sets - Do not allow accelerators in the menu like "z", because they do not go through selector-based command matching and always fire into the window. - Do not match `cmdctrl` to both `cmd` and `ctrl` on the Mac. Just `cmd` - Re-order `shift-delete` mapping to `core:cut`, because it causes the menu to have no binding on Mac OS X
This commit is contained in:
parent
83510d0cef
commit
6ef0a49c26
5 changed files with 24 additions and 31 deletions
|
@ -23,11 +23,11 @@
|
|||
'cmdctrl-z': 'core:undo'
|
||||
'cmdctrl-Z': 'core:redo'
|
||||
'cmdctrl-y': 'core:redo'
|
||||
'shift-delete': 'core:cut'
|
||||
'cmdctrl-x': 'core:cut'
|
||||
'cmdctrl-c': 'core:copy'
|
||||
'cmdctrl-v': 'core:paste'
|
||||
'cmdctrl-a': 'core:select-all'
|
||||
'shift-delete': 'core:cut'
|
||||
|
||||
'up' : 'core:previous-item'
|
||||
'down' : 'core:next-item'
|
||||
|
|
|
@ -4,13 +4,13 @@
|
|||
'body':
|
||||
# Windows email-specific menu items
|
||||
'cmdctrl-shift-v': 'application:change-category' # Outlook
|
||||
'F3': 'application:focus-search'
|
||||
'F3': 'application:focus-search'
|
||||
'cmdctrl-e': 'application:focus-search'
|
||||
'cmdctrl-f': 'application:forward'
|
||||
'cmdctrl-shift-v': 'application:change-category'
|
||||
'cmdctrl-d': 'application:delete-item'
|
||||
'alt-backspace':'core:undo'
|
||||
'alt-s': 'application:send-message'
|
||||
'alt-backspace': 'core:undo'
|
||||
'alt-s': 'application:send-message'
|
||||
'cmdctrl-r': 'application:reply'
|
||||
'cmdctrl-shift-r': 'application:reply-all'
|
||||
'cmdctrl-n' : 'application:new-message'
|
||||
|
|
|
@ -415,23 +415,19 @@ class Application
|
|||
sendCommand: (command, args...) ->
|
||||
unless @emit(command, args...)
|
||||
focusedWindow = @windowManager.focusedWindow()
|
||||
focusedBrowserWindow = BrowserWindow.getFocusedWindow()
|
||||
mainWindow = @windowManager.mainWindow()
|
||||
|
||||
if focusedWindow?
|
||||
if focusedWindow
|
||||
focusedWindow.sendCommand(command, args...)
|
||||
else if focusedBrowserWindow?
|
||||
# Note: We sometimes display non-"AtomWindow" windows, for things like
|
||||
# raw message contents. Ensure that these also get to run window commands
|
||||
unless @sendCommandToFirstResponder(command)
|
||||
switch command
|
||||
when 'window:reload' then focusedBrowserWindow.reload()
|
||||
when 'window:toggle-dev-tools' then focusedBrowserWindow.toggleDevTools()
|
||||
when 'window:close' then focusedBrowserWindow.close()
|
||||
else if mainWindow?
|
||||
mainWindow.sendCommand(command, args...)
|
||||
else
|
||||
@sendCommandToFirstResponder(command)
|
||||
unless @sendCommandToFirstResponder(command)
|
||||
focusedBrowserWindow = BrowserWindow.getFocusedWindow()
|
||||
mainWindow = @windowManager.mainWindow()
|
||||
if focusedBrowserWindow
|
||||
switch command
|
||||
when 'window:reload' then focusedBrowserWindow.reload()
|
||||
when 'window:toggle-dev-tools' then focusedBrowserWindow.toggleDevTools()
|
||||
when 'window:close' then focusedBrowserWindow.close()
|
||||
else if mainWindow
|
||||
mainWindow.sendCommand(command, args...)
|
||||
|
||||
# Public: Executes the given command on the given window.
|
||||
#
|
||||
|
|
|
@ -1,20 +1,16 @@
|
|||
KeymapUtils =
|
||||
cmdCtrlPreprocessor: (keymap={}) ->
|
||||
re = /(cmdctrl|ctrlcmd)/i
|
||||
if process.platform is "darwin"
|
||||
cmdctrl = 'cmd'
|
||||
else
|
||||
cmdctrl = 'ctrl'
|
||||
|
||||
for selector, keyBindings of keymap
|
||||
normalizedBindings = {}
|
||||
for keystrokes, command of keyBindings
|
||||
if re.test keystrokes
|
||||
if process.platform is "darwin"
|
||||
newKeystrokes1= keystrokes.replace(re, "ctrl")
|
||||
newKeystrokes2= keystrokes.replace(re, "cmd")
|
||||
normalizedBindings[newKeystrokes1] = command
|
||||
normalizedBindings[newKeystrokes2] = command
|
||||
else
|
||||
newKeystrokes = keystrokes.replace(re, "ctrl")
|
||||
normalizedBindings[newKeystrokes] = command
|
||||
else
|
||||
normalizedBindings[keystrokes] = command
|
||||
keystrokes = keystrokes.replace(re, cmdctrl)
|
||||
normalizedBindings[keystrokes] = command
|
||||
keymap[selector] = normalizedBindings
|
||||
|
||||
return keymap
|
||||
|
|
|
@ -64,6 +64,7 @@ class MenuManager
|
|||
@pendingUpdateOperation = null
|
||||
@template = []
|
||||
atom.keymaps.onDidLoadBundledKeymaps => @loadPlatformItems()
|
||||
atom.keymaps.onDidReloadKeymap => @update()
|
||||
atom.packages.onDidActivateInitialPackages => @sortPackagesMenu()
|
||||
|
||||
# Public: Adds the given items to the application menu.
|
||||
|
@ -165,7 +166,7 @@ class MenuManager
|
|||
for key, bindings of keystrokesByCommand
|
||||
for binding in bindings
|
||||
continue if binding.indexOf(' ') != -1
|
||||
|
||||
continue unless /(cmd|ctrl|shift|alt)/.test(binding)
|
||||
filtered[key] ?= []
|
||||
filtered[key].push(binding)
|
||||
filtered
|
||||
|
|
Loading…
Reference in a new issue