diff --git a/src/document/DocumentCommandHandlers.js b/src/document/DocumentCommandHandlers.js index e95b1979e95..0ceb1f3baba 100644 --- a/src/document/DocumentCommandHandlers.js +++ b/src/document/DocumentCommandHandlers.js @@ -236,8 +236,7 @@ define(function (require, exports, module) { fullPath = commandData.fullPath; } - return _doOpenWithOptionalPath(fullPath) - .always(EditorManager.focusEditor); + return _doOpenWithOptionalPath(fullPath); } /** @@ -742,7 +741,11 @@ define(function (require, exports, module) { } function handleFileRename() { - ProjectManager.renameSelectedItem(); + var promise = CommandManager.execute(Commands.NAVIGATE_SHOW_IN_FILE_TREE, {fileEntry: DocumentManager.getCurrentDocument().file}); + promise + .done(function ($node) { + ProjectManager.renameSelectedItem(); + }); } /** Closes the window, then quits the app */ @@ -812,7 +815,7 @@ define(function (require, exports, module) { } function handleShowInTree() { - ProjectManager.showInTree(DocumentManager.getCurrentDocument().file); + return ProjectManager.showInTree(DocumentManager.getCurrentDocument().file); } diff --git a/src/project/ProjectManager.js b/src/project/ProjectManager.js index e639ab5560d..eedba26cb30 100644 --- a/src/project/ProjectManager.js +++ b/src/project/ProjectManager.js @@ -826,11 +826,13 @@ define(function (require, exports, module) { } function showInTree(fileEntry) { - _findTreeNode(fileEntry) + var promise = _findTreeNode(fileEntry); + promise .done(function ($node) { // jsTree will automatically expand parent nodes to ensure visible _projectTree.jstree("select_node", $node, false); }); + return promise; } diff --git a/src/project/SidebarView.js b/src/project/SidebarView.js index f1774dda4fa..d5cc895c9b8 100644 --- a/src/project/SidebarView.js +++ b/src/project/SidebarView.js @@ -42,6 +42,7 @@ define(function (require, exports, module) { Strings = require("strings"), PreferencesManager = require("preferences/PreferencesManager"), EditorManager = require("editor/EditorManager"), + KeyBindingManager = require("command/KeyBindingManager"), Global = require("utils/Global"); var isSidebarClosed = false; @@ -249,7 +250,18 @@ define(function (require, exports, module) { e.preventDefault(); }); } - + + function _initSidebarKeyBinding() { + $sidebar.focus(function () { + KeyBindingManager.addBinding(Commands.FILE_RENAME, [{key: "F2", platform: "win"}, + {key: "Enter", platform: "mac"}]); + }); + $sidebar.blur(function (event) { + KeyBindingManager.removeBinding("F2", "win"); + KeyBindingManager.removeBinding("Enter", "mac"); + }); + } + // Initialize items dependent on HTML DOM AppInit.htmlReady(function () { $sidebar = $("#sidebar"); @@ -259,9 +271,13 @@ define(function (require, exports, module) { $projectTitle = $("#project-title"); $projectFilesContainer = $("#project-files-container"); + // make sidebar focusable + $sidebar.attr("tabindex", "0"); + // init WorkingSetView.create($openFilesContainer); _initSidebarResizer(); + _initSidebarKeyBinding(); }); $(ProjectManager).on("projectOpen", _updateProjectTitle); diff --git a/src/project/WorkingSetView.js b/src/project/WorkingSetView.js index 1f7c326efae..670342a4393 100644 --- a/src/project/WorkingSetView.js +++ b/src/project/WorkingSetView.js @@ -176,7 +176,6 @@ define(function (require, exports, module) { $newItem.mousedown(function (e) { FileViewController.openAndSelectDocument(file.fullPath, FileViewController.WORKING_SET_VIEW); - e.preventDefault(); }); $newItem.hover(