From f27e363b6879d6a3e064ee45e91fafcb770ad465 Mon Sep 17 00:00:00 2001 From: David Rowe Date: Wed, 2 May 2018 15:23:13 +1200 Subject: [PATCH] Remove entity from list when it deletes; handle multiple deletions --- scripts/system/edit.js | 17 ++++++++++++++++- scripts/system/libraries/entitySelectionTool.js | 11 +++++++++++ 2 files changed, 27 insertions(+), 1 deletion(-) diff --git a/scripts/system/edit.js b/scripts/system/edit.js index 9b6b70b954..6bb815a597 100644 --- a/scripts/system/edit.js +++ b/scripts/system/edit.js @@ -471,8 +471,23 @@ var toolBar = (function () { } } + var entitiesToDelete = []; + var deletedEntityTimer = null; + var DELETE_ENTITY_TIMER_TIMEOUT = 100; + function checkDeletedEntityAndUpdate(entityID) { - selectionManager.removeEntity(entityID); + // Allow for multiple entity deletes before updating the entity list. + entitiesToDelete.push(entityID); + if (deletedEntityTimer !== null) { + Script.clearTimeout(deletedEntityTimer); + } + deletedEntityTimer = Script.setTimeout(function () { + selectionManager.removeEntities(entitiesToDelete); + entityListTool.clearEntityList(); + entityListTool.sendUpdate(); + entitiesToDelete = []; + deletedEntityTimer = null; + }, DELETE_ENTITY_TIMER_TIMEOUT); } function initialize() { diff --git a/scripts/system/libraries/entitySelectionTool.js b/scripts/system/libraries/entitySelectionTool.js index 2322210522..4996579799 100644 --- a/scripts/system/libraries/entitySelectionTool.js +++ b/scripts/system/libraries/entitySelectionTool.js @@ -149,6 +149,17 @@ SelectionManager = (function() { that._update(true); }; + that.removeEntities = function (entityIDs) { + for (var i = 0, length = entityIDs.length; i < length; i++) { + var idx = that.selections.indexOf(entityIDs[i]); + if (idx >= 0) { + that.selections.splice(idx, 1); + Selection.removeFromSelectedItemsList(HIGHLIGHT_LIST_NAME, "entity", entityIDs[i]); + } + } + that._update(true); + }; + that.clearSelections = function() { that.selections = []; that._update(true);