Merge pull request #13075 from ctrlaltdavid/21862

Clear entity selection handles and update list when entities are deleted
This commit is contained in:
Liv 2018-05-04 14:23:37 -07:00 committed by GitHub
commit e4b6686e1c
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 34 additions and 2 deletions

View file

@ -471,6 +471,25 @@ var toolBar = (function () {
}
}
var entitiesToDelete = [];
var deletedEntityTimer = null;
var DELETE_ENTITY_TIMER_TIMEOUT = 100;
function checkDeletedEntityAndUpdate(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() {
Script.scriptEnding.connect(cleanup);
Window.domainChanged.connect(function () {
@ -493,8 +512,10 @@ var toolBar = (function () {
Entities.canRezTmpChanged.connect(checkEditPermissionsAndUpdate);
Entities.canRezCertifiedChanged.connect(checkEditPermissionsAndUpdate);
Entities.canRezTmpCertifiedChanged.connect(checkEditPermissionsAndUpdate);
var hasRezPermissions = (Entities.canRez() || Entities.canRezTmp() || Entities.canRezCertified() || Entities.canRezTmpCertified());
Entities.deletingEntity.connect(checkDeletedEntityAndUpdate);
var createButtonIconRsrc = (hasRezPermissions ? CREATE_ENABLED_ICON : CREATE_DISABLED_ICON);
tablet = Tablet.getTablet("com.highfidelity.interface.tablet.system");
activeButton = tablet.addButton({

View file

@ -140,12 +140,23 @@ SelectionManager = (function() {
that._update(true);
};
that.removeEntity = function(entityID) {
function removeEntityByID(entityID) {
var idx = that.selections.indexOf(entityID);
if (idx >= 0) {
that.selections.splice(idx, 1);
Selection.removeFromSelectedItemsList(HIGHLIGHT_LIST_NAME, "entity", entityID);
}
}
that.removeEntity = function (entityID) {
removeEntityByID(entityID);
that._update(true);
};
that.removeEntities = function(entityIDs) {
for (var i = 0, length = entityIDs.length; i < length; i++) {
removeEntityByID(entityIDs[i]);
}
that._update(true);
};