Fixes #151, Allow Tab and Shift-Tab into and out of notes
This commit is contained in:
parent
0d0585b217
commit
9d7cc849cd
|
@ -268,11 +268,28 @@
|
||||||
<body>
|
<body>
|
||||||
<![CDATA[
|
<![CDATA[
|
||||||
switch (event.keyCode) {
|
switch (event.keyCode) {
|
||||||
// Insert tab manually
|
|
||||||
case 9:
|
case 9:
|
||||||
if (event.shiftKey || event.ctrlKey || event.altKey) {
|
if (event.ctrlKey || event.altKey) {
|
||||||
return;
|
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
|
// From http://kb.mozillazine.org/Inserting_text_at_cursor
|
||||||
try {
|
try {
|
||||||
var command = "cmd_insertText";
|
var command = "cmd_insertText";
|
||||||
|
@ -289,9 +306,6 @@
|
||||||
Zotero.debug("Can't do cmd_insertText!\n" + e, 1);
|
Zotero.debug("Can't do cmd_insertText!\n" + e, 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
event.stopPropagation();
|
|
||||||
event.preventDefault();
|
|
||||||
|
|
||||||
// DEBUG: is there a better way to prevent blur()?
|
// DEBUG: is there a better way to prevent blur()?
|
||||||
setTimeout(function() { event.target.focus(); }, 1);
|
setTimeout(function() { event.target.focus(); }, 1);
|
||||||
break;
|
break;
|
||||||
|
|
|
@ -90,7 +90,7 @@
|
||||||
|
|
||||||
<!-- Note item -->
|
<!-- Note item -->
|
||||||
<groupbox id="zotero-view-note" flex="1">
|
<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'));"/>
|
<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>
|
</groupbox>
|
||||||
|
|
||||||
|
|
|
@ -509,6 +509,19 @@ var ZoteroPane = new function()
|
||||||
|
|
||||||
return;
|
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
|
// Ignore keystrokes if Zotero pane is closed
|
||||||
var zoteroPane = document.getElementById('zotero-pane-stack');
|
var zoteroPane = document.getElementById('zotero-pane-stack');
|
||||||
|
|
|
@ -331,6 +331,7 @@
|
||||||
id="zotero-items-tree" context="zotero-itemmenu"
|
id="zotero-items-tree" context="zotero-itemmenu"
|
||||||
enableColumnDrag="true"
|
enableColumnDrag="true"
|
||||||
onfocus="if (ZoteroPane_Local.itemsView.rowCount && !ZoteroPane_Local.itemsView.selection.count) { ZoteroPane_Local.itemsView.selection.select(0); }"
|
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)"
|
onkeypress="ZoteroPane_Local.handleKeyPress(event, this.id)"
|
||||||
onselect="ZoteroPane_Local.itemSelected(event)"
|
onselect="ZoteroPane_Local.itemSelected(event)"
|
||||||
ondragstart="if (event.target.localName == 'treechildren') { ZoteroPane_Local.itemsView.onDragStart(event); }"
|
ondragstart="if (event.target.localName == 'treechildren') { ZoteroPane_Local.itemsView.onDragStart(event); }"
|
||||||
|
|
Loading…
Reference in New Issue
Block a user