Remove entity from list when it deletes; handle multiple deletions

This commit is contained in:
David Rowe 2018-05-02 15:23:13 +12:00
parent 5a064d3499
commit f27e363b68
2 changed files with 27 additions and 1 deletions

View file

@ -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() {

View file

@ -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);