commit 9d7cc849cdd924901dd491e067f11086f93d0f58
parent 0d0585b2172c643ddbcd5441c95b5fc124a7055a
Author: Dan Stillman <dstillman@zotero.org>
Date: Thu, 1 Nov 2012 03:32:07 -0400
Fixes #151, Allow Tab and Shift-Tab into and out of notes
Diffstat:
4 files changed, 34 insertions(+), 6 deletions(-)
diff --git a/chrome/content/zotero/bindings/noteeditor.xml b/chrome/content/zotero/bindings/noteeditor.xml
@@ -268,11 +268,28 @@
<body>
<![CDATA[
switch (event.keyCode) {
- // Insert tab manually
case 9:
- if (event.shiftKey || event.ctrlKey || event.altKey) {
+ if (event.ctrlKey || event.altKey) {
return;
}
+
+ event.stopPropagation();
+ event.preventDefault();
+
+ // On shift-tab, focus the element specified in
+ // the 'previousfocus' attribute
+ if (event.shiftKey) {
+ let id = this.getAttribute('previousfocus');
+ if (id) {
+ setTimeout(function () {
+ document.getElementById(id).focus();
+ }, 0);
+ }
+ return;
+ }
+
+ // Insert tab manually
+ //
// From http://kb.mozillazine.org/Inserting_text_at_cursor
try {
var command = "cmd_insertText";
@@ -289,9 +306,6 @@
Zotero.debug("Can't do cmd_insertText!\n" + e, 1);
}
- event.stopPropagation();
- event.preventDefault();
-
// DEBUG: is there a better way to prevent blur()?
setTimeout(function() { event.target.focus(); }, 1);
break;
diff --git a/chrome/content/zotero/itemPane.xul b/chrome/content/zotero/itemPane.xul
@@ -90,7 +90,7 @@
<!-- Note item -->
<groupbox id="zotero-view-note" flex="1">
- <zoteronoteeditor id="zotero-note-editor" flex="1" notitle="1"/>
+ <zoteronoteeditor id="zotero-note-editor" flex="1" notitle="1" previousfocus="zotero-items-tree"/>
<button id="zotero-view-note-button" label="&zotero.notes.separate;" oncommand="ZoteroPane_Local.openNoteWindow(this.getAttribute('noteID')); if(this.hasAttribute('sourceID')) ZoteroPane_Local.selectItem(this.getAttribute('sourceID'));"/>
</groupbox>
diff --git a/chrome/content/zotero/zoteroPane.js b/chrome/content/zotero/zoteroPane.js
@@ -509,6 +509,19 @@ var ZoteroPane = new function()
return;
}
+ else if (from == 'zotero-items-tree') {
+ // Focus TinyMCE explicitly on tab key, since the normal focusing
+ // doesn't work right
+ if (!event.shiftKey && event.keyCode == event.DOM_VK_TAB) {
+ var deck = document.getElementById('zotero-item-pane-content');
+ if (deck.selectedPanel.id == 'zotero-view-note') {
+ setTimeout(function () {
+ document.getElementById('zotero-note-editor').focus();
+ }, 0);
+ }
+ }
+ return;
+ }
// Ignore keystrokes if Zotero pane is closed
var zoteroPane = document.getElementById('zotero-pane-stack');
diff --git a/chrome/content/zotero/zoteroPane.xul b/chrome/content/zotero/zoteroPane.xul
@@ -331,6 +331,7 @@
id="zotero-items-tree" context="zotero-itemmenu"
enableColumnDrag="true"
onfocus="if (ZoteroPane_Local.itemsView.rowCount && !ZoteroPane_Local.itemsView.selection.count) { ZoteroPane_Local.itemsView.selection.select(0); }"
+ onkeydown="ZoteroPane_Local.handleKeyDown(event, this.id)"
onkeypress="ZoteroPane_Local.handleKeyPress(event, this.id)"
onselect="ZoteroPane_Local.itemSelected(event)"
ondragstart="if (event.target.localName == 'treechildren') { ZoteroPane_Local.itemsView.onDragStart(event); }"