From c0d6648b9eaf440e8a31d01ea50a0b2488e22320 Mon Sep 17 00:00:00 2001 From: Dan Stillman Date: Sat, 31 May 2014 14:20:53 -0400 Subject: [PATCH] Allow inline editing of collection names 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 --- .../zotero/xpcom/collectionTreeView.js | 23 ++++++++++++++++++- chrome/content/zotero/zoteroPane.xul | 2 +- 2 files changed, 23 insertions(+), 2 deletions(-) diff --git a/chrome/content/zotero/xpcom/collectionTreeView.js b/chrome/content/zotero/xpcom/collectionTreeView.js index eeb42e6d0..c9bd98987 100644 --- a/chrome/content/zotero/xpcom/collectionTreeView.js +++ b/chrome/content/zotero/xpcom/collectionTreeView.js @@ -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; }); @@ -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) { diff --git a/chrome/content/zotero/zoteroPane.xul b/chrome/content/zotero/zoteroPane.xul index 301873cc1..7bb90bea8 100644 --- a/chrome/content/zotero/zoteroPane.xul +++ b/chrome/content/zotero/zoteroPane.xul @@ -301,7 +301,7 @@ + seltype="cell" flex="1" editable="true">