Fixes #151, Allow Tab and Shift-Tab into and out of notes

This commit is contained in:
Dan Stillman 2012-11-01 03:32:07 -04:00
parent 0d0585b217
commit 9d7cc849cd
4 changed files with 34 additions and 6 deletions

View file

@ -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;

View file

@ -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>

View file

@ -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');

View file

@ -331,6 +331,7 @@
id="zotero-items-tree" context="zotero-itemmenu"
enableColumnDrag="true"
onfocus="if (ZoteroPane_Local.itemsView.rowCount &amp;&amp; !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); }"