Skip to content

Commit

Permalink
Allow inline editing of collection names
Browse files Browse the repository at this point in the history
Can be triggered by double-clicking or Return and also by F2 on
Windows/Linux

This does mean double-clicking no longer toggles the collection open and
closed. If we wanted to preserve that we could probably capture the
double-click.

Closes Trac ticket 231, only 8 years later
  • Loading branch information
dstillman committed May 31, 2014
1 parent 326d2bc commit c0d6648
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 2 deletions.
23 changes: 22 additions & 1 deletion chrome/content/zotero/xpcom/collectionTreeView.js
Expand Up @@ -575,6 +575,28 @@ Zotero.CollectionTreeView.prototype.isSelectable = function (row, col) {
}


/**
* Tree method for whether to allow inline editing (not to be confused with this.editable)
*/
Zotero.CollectionTreeView.prototype.isEditable = function (row, col) {
return this.itemGroup.isCollection() && this.editable;
}


Zotero.CollectionTreeView.prototype.setCellText = function (row, col, val) {
val = val.trim();
if (val === "") {
return;
}
this.itemGroup.ref.name = val;
this.itemGroup.ref.save();
}



/**
* Returns TRUE if the underlying view is editable
*/
Zotero.CollectionTreeView.prototype.__defineGetter__('editable', function () {
return this._getItemAtRow(this.selection.currentIndex).editable;
});
Expand Down Expand Up @@ -1803,7 +1825,6 @@ Zotero.CollectionTreeView.prototype.drop = function(row, orient, dataTransfer)
////////////////////////////////////////////////////////////////////////////////

Zotero.CollectionTreeView.prototype.isSorted = function() { return false; }
Zotero.CollectionTreeView.prototype.isEditable = function(row, idx) { return false; }

/* Set 'highlighted' property on rows set by setHighlightedRows */
Zotero.CollectionTreeView.prototype.getRowProperties = function(row, prop) {
Expand Down
2 changes: 1 addition & 1 deletion chrome/content/zotero/zoteroPane.xul
Expand Up @@ -301,7 +301,7 @@
<tree id="zotero-collections-tree" hidecolumnpicker="true" context="zotero-collectionmenu"
onmouseover="ZoteroPane_Local.collectionsView.setHighlightedRows();"
onselect="ZoteroPane_Local.onCollectionSelected();"
seltype="cell" flex="1">
seltype="cell" flex="1" editable="true">
<treecols>
<treecol
id="zotero-collections-name-column"
Expand Down

0 comments on commit c0d6648

Please sign in to comment.