Skip to content
This repository was archived by the owner on Sep 6, 2021. It is now read-only.

Commit dae45b1

Browse files
committed
Merge pull request #7955 from adobe/ryanstewart/issue1976
Addresses #1976 by implementing click->hold to rename for the project tr...
2 parents 0149fa9 + 6b7122d commit dae45b1

File tree

1 file changed

+24
-1
lines changed

1 file changed

+24
-1
lines changed

src/project/ProjectManager.js

Lines changed: 24 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -207,6 +207,13 @@ define(function (require, exports, module) {
207207
*/
208208
var _dirFirst;
209209

210+
/**
211+
* @private
212+
* @type {Number}
213+
* Tracks the timeoutID for mouseup events.
214+
*/
215+
var _mouseupTimeoutId = null;
216+
210217
/**
211218
* @private
212219
* Generates the prefixes used for sorting the files in the project tree
@@ -656,7 +663,18 @@ define(function (require, exports, module) {
656663
}
657664
}
658665
}
659-
);
666+
).bind("mouseup.jstree", function (event) {
667+
var $treenode = $(event.target).closest("li");
668+
if ($treenode.is($(_projectTree.jstree("get_selected")))) {
669+
// wrap this in a setTimeout function so that we can check if it's a double click.
670+
_mouseupTimeoutId = window.setTimeout(function (event) {
671+
// if we get a double-click,_mouseupTimeoutId will have been set to lull by the double-click handler before this runs.
672+
if (_mouseupTimeoutId !== null) {
673+
CommandManager.execute(Commands.FILE_RENAME);
674+
}
675+
}, 500);
676+
}
677+
});
660678

661679
// jstree has a default event handler for dblclick that attempts to clear the
662680
// global window selection (presumably because it doesn't want text within the tree
@@ -718,6 +736,11 @@ define(function (require, exports, module) {
718736
if (entry && entry.isFile && !_isInRename(event.target)) {
719737
FileViewController.addToWorkingSetAndSelect(entry.fullPath);
720738
}
739+
if (_mouseupTimeoutId !== null) {
740+
window.clearTimeout(_mouseupTimeoutId);
741+
_mouseupTimeoutId = null;
742+
}
743+
721744
});
722745

723746
// fire selection changed events for sidebar-selection

0 commit comments

Comments
 (0)