fix addselection starting selection

Signed-off-by: Victor Seiji Hariki <victorseijih@gmail.com>
This commit is contained in:
Victor Seiji Hariki 2022-12-23 22:18:37 -03:00
parent cfca5d95ba
commit 92ab54282d

View file

@ -41,12 +41,6 @@ const stampTool = () =>
mouse.listen.world.btn.left.onclick.clear(state.drawcb); mouse.listen.world.btn.left.onclick.clear(state.drawcb);
mouse.listen.world.btn.right.onclick.clear(state.cancelcb); mouse.listen.world.btn.right.onclick.clear(state.cancelcb);
// Deselect
state.selected = null;
Array.from(state.ctxmenu.resourceList.children).forEach((child) => {
child.classList.remove("active");
});
ovLayer.clear(); ovLayer.clear();
}, },
{ {
@ -60,7 +54,7 @@ const stampTool = () =>
state.lastMouseMove = {x: 0, y: 0}; state.lastMouseMove = {x: 0, y: 0};
state.block_res_change = true; state.block_res_change = true;
state.selectResource = (resource, nolock = true) => { state.selectResource = (resource, nolock = true, deselect = true) => {
if (nolock && state.ctxmenu.uploadButton.disabled) return; if (nolock && state.ctxmenu.uploadButton.disabled) return;
console.debug( console.debug(
@ -83,14 +77,14 @@ const stampTool = () =>
resourceWrapper && resourceWrapper.classList.add("active"); resourceWrapper && resourceWrapper.classList.add("active");
state.selected = resource; state.selected = resource;
} }
// If already selected, clear selection // If already selected, clear selection (if deselection is enabled)
else { else if (deselect){
resourceWrapper.classList.remove("active"); resourceWrapper.classList.remove("active");
state.selected = null; state.selected = null;
} }
ovLayer.clear(); ovLayer.clear();
if (state.loaded) state.movecb(state.lastMouseMove); if (state.loaded) state.redraw();
}; };
// Open IndexedDB connection // Open IndexedDB connection
@ -277,7 +271,7 @@ const stampTool = () =>
syncResources(); syncResources();
// Select this resource // Select this resource
state.selectResource(resource, nolock); state.selectResource(resource, nolock, false);
return resource; return resource;
}; };