From 4069ca2e0c39a51d1b3eb911d62a19439c3c0b9d Mon Sep 17 00:00:00 2001 From: Thijs Wenker Date: Sat, 20 Oct 2018 02:43:41 +0200 Subject: [PATCH] CR feedback --- scripts/system/html/js/entityList.js | 11 ++++---- .../system/html/js/entityListContextMenu.js | 27 +++++++++---------- 2 files changed, 19 insertions(+), 19 deletions(-) diff --git a/scripts/system/html/js/entityList.js b/scripts/system/html/js/entityList.js index 749f750ecb..663acb758c 100644 --- a/scripts/system/html/js/entityList.js +++ b/scripts/system/html/js/entityList.js @@ -231,8 +231,11 @@ function loaded() { elRenameInput.select(); } - entityListContextMenu.setCallback(function(optionName, selectedEntityID) { + entityListContextMenu.setOnSelectedCallback(function(optionName, selectedEntityID) { switch (optionName) { + case "Cut": + EventBridge.emitWebEvent(JSON.stringify({ type: 'cut' })); + break; case "Copy": EventBridge.emitWebEvent(JSON.stringify({ type: 'copy' })); break; @@ -263,8 +266,6 @@ function loaded() { focus: false, entityIds: selection, })); - - refreshFooter(); } let enabledContextMenuItems = []; @@ -765,7 +766,7 @@ function loaded() { augmentSpinButtons(); document.addEventListener("contextmenu", function (event) { - entityListContextMenu.close.call(entityListContextMenu); + entityListContextMenu.close(); // Disable default right-click context menu which is not visible in the HMD and makes it seem like the app has locked event.preventDefault(); @@ -773,6 +774,6 @@ function loaded() { // close context menu when switching focus to another window $(window).blur(function() { - entityListContextMenu.close.call(entityListContextMenu); + entityListContextMenu.close(); }); } diff --git a/scripts/system/html/js/entityListContextMenu.js b/scripts/system/html/js/entityListContextMenu.js index 62fe951ebe..d71719f252 100644 --- a/scripts/system/html/js/entityListContextMenu.js +++ b/scripts/system/html/js/entityListContextMenu.js @@ -18,7 +18,7 @@ const CONTEXT_MENU_CLASS = "context-menu"; */ function EntityListContextMenu() { this._elContextMenu = null; - this._callback = null; + this._onSelectedCallback = null; this._listItems = []; this._initialize(); } @@ -33,7 +33,7 @@ EntityListContextMenu.prototype = { /** * @private */ - _callback: null, + _onSelectedCallback: null, /** * @private @@ -82,20 +82,19 @@ EntityListContextMenu.prototype = { }, /** - * Set the event callback - * @param callback + * Set the callback for when a menu item is selected + * @param onSelectedCallback */ - setCallback: function(callback) { - this._callback = callback; + setOnSelectedCallback: function(onSelectedCallback) { + this._onSelectedCallback = onSelectedCallback; }, /** * Add a labeled item to the context menu * @param itemLabel - * @param isEnabled * @private */ - _addListItem: function(itemLabel, isEnabled) { + _addListItem: function(itemLabel) { let elListItem = document.createElement("li"); elListItem.innerText = itemLabel; @@ -106,8 +105,8 @@ EntityListContextMenu.prototype = { }; elListItem.addEventListener("click", function () { - if (listItem.enabled && this._callback) { - this._callback.call(this, itemLabel, this._selectedEntityID); + if (listItem.enabled && this._onSelectedCallback) { + this._onSelectedCallback.call(this, itemLabel, this._selectedEntityID); } }.bind(this), false); @@ -136,12 +135,12 @@ EntityListContextMenu.prototype = { this._elContextMenu.setAttribute("class", CONTEXT_MENU_CLASS); document.body.appendChild(this._elContextMenu); - // TODO: enable Copy, Paste and Duplicate items once implemented - this._addListItem("Copy", false); - this._addListItem("Paste", false); + this._addListItem("Cut"); + this._addListItem("Copy"); + this._addListItem("Paste"); this._addListSeparator(); this._addListItem("Rename"); - this._addListItem("Duplicate", false); + this._addListItem("Duplicate"); this._addListItem("Delete"); // Ignore clicks on context menu background or separator.