From 292c357e4a80af221b0e7a627ac4acb2e0173019 Mon Sep 17 00:00:00 2001 From: Dan Stillman Date: Tue, 13 May 2008 19:20:39 +0000 Subject: [PATCH] Shortcut key handling improvements: - Fix Cmd-Shift-Z on Fx3/Mac when Zotero pane is open - Don't override Redo on Fx3/Mac even if the override pref is set, since it can coexist -- this lets Redo be used within textboxes - Ignore Zotero shortcuts (other than master shortcut) when Zotero pane isn't focused This needs testing. --- chrome/content/zotero/overlay.js | 13 +++++++++++++ chrome/content/zotero/xpcom/zotero.js | 10 ++++++++-- 2 files changed, 21 insertions(+), 2 deletions(-) diff --git a/chrome/content/zotero/overlay.js b/chrome/content/zotero/overlay.js index ae5e6f437..43dbea8e4 100644 --- a/chrome/content/zotero/overlay.js +++ b/chrome/content/zotero/overlay.js @@ -349,6 +349,16 @@ var ZoteroPane = new function() * Trigger actions based on keyboard shortcuts */ function handleKeyDown(event, from) { + try { + // Ignore keystrokes outside of Zotero pane + if (!(event.originalTarget.ownerDocument instanceof XULDocument)) { + return; + } + } + catch (e) { + Zotero.debug(e); + } + if (from == 'zotero-pane') { // Highlight collections containing selected items // @@ -406,6 +416,9 @@ var ZoteroPane = new function() Zotero.debug(command); switch (command) { + case 'openZotero': + ZoteroPane.toggleDisplay() + break; case 'library': document.getElementById('zotero-collections-tree').focus(); ZoteroPane.collectionsView.selection.select(0); diff --git a/chrome/content/zotero/xpcom/zotero.js b/chrome/content/zotero/xpcom/zotero.js index d925d333d..1b5186500 100644 --- a/chrome/content/zotero/xpcom/zotero.js +++ b/chrome/content/zotero/xpcom/zotero.js @@ -987,7 +987,7 @@ Zotero.Keys = new function() { this.windowInit = windowInit; this.getCommand = getCommand; - _keys = {}; + var _keys = {}; /* @@ -1019,7 +1019,7 @@ Zotero.Keys = new function() { // Only override the default with the pref if the hasn't been manually changed // and the pref has been if (keyElem.getAttribute('key') == 'Z' && keyElem.getAttribute('modifiers') == 'accel alt' - && (zKey != 'Z' || useShift)) { + && (zKey != 'Z' || useShift)) { keyElem.setAttribute('key', zKey); if (useShift) { keyElem.setAttribute('modifiers', 'accel shift'); @@ -1050,6 +1050,12 @@ Zotero.Keys = new function() { } if (_keys[key.getAttribute('key')] || key.getAttribute('key') == zKey) { + // Don't override Redo on Fx3 Mac, since Redo and Zotero can coexist + if (zKey == 'Z' && key.getAttribute('key') == 'Z' + && id == 'key_redo' && Zotero.isFx3 && Zotero.isMac) { + continue; + } + Zotero.debug('Removing key ' + id + ' with accesskey ' + key.getAttribute('key')); key.parentNode.removeChild(key); }