mirror of
https://github.com/scratchfoundation/scratch-paint.git
synced 2024-12-22 21:42:30 -05:00
Fix an issue where undoing when there is a bounding box would cause the whole layer to be selected
This commit is contained in:
parent
dbe24ed50c
commit
d6fc238359
3 changed files with 9 additions and 12 deletions
|
@ -33,6 +33,7 @@ class MoveTool {
|
|||
* select the whole group.
|
||||
*/
|
||||
onMouseDown (hitProperties) {
|
||||
debugger;
|
||||
let item = hitProperties.hitResult.item;
|
||||
if (!hitProperties.subselect) {
|
||||
const root = getRootItem(hitProperties.hitResult.item);
|
||||
|
|
|
@ -126,22 +126,18 @@ const clearSelection = function (dispatchClearSelect) {
|
|||
* @return {Array<paper.Item>} in increasing Z order.
|
||||
*/
|
||||
const getSelectedRootItems = function () {
|
||||
const allItems = paper.project.selectedItems;
|
||||
const itemsAndGroups = [];
|
||||
const allItems = getAllSelectableRootItems();
|
||||
const items = [];
|
||||
|
||||
for (let i = 0; i < allItems.length; i++) {
|
||||
const item = allItems[i];
|
||||
if ((isGroup(item) && !isGroup(item.parent)) ||
|
||||
!isGroup(item.parent)) {
|
||||
if (item.data && !item.data.isSelectionBound) {
|
||||
itemsAndGroups.push(item);
|
||||
}
|
||||
for (const item of allItems) {
|
||||
if (item.selected) {
|
||||
items.push(item);
|
||||
}
|
||||
}
|
||||
|
||||
// sort items by index (0 at bottom)
|
||||
itemsAndGroups.sort((a, b) => parseFloat(a.index) - parseFloat(b.index));
|
||||
return itemsAndGroups;
|
||||
items.sort((a, b) => parseFloat(a.index) - parseFloat(b.index));
|
||||
return items;
|
||||
};
|
||||
|
||||
/**
|
||||
|
|
|
@ -21,7 +21,7 @@ class RectTool extends paper.Tool {
|
|||
this.clearSelectedItems = clearSelectedItems;
|
||||
this.onUpdateSvg = onUpdateSvg;
|
||||
this.prevHoveredItemId = null;
|
||||
this.boundingBoxTool = new BoundingBoxTool(Modes.SELECT, setSelectedItems, clearSelectedItems, onUpdateSvg);
|
||||
this.boundingBoxTool = new BoundingBoxTool(Modes.RECT, setSelectedItems, clearSelectedItems, onUpdateSvg);
|
||||
|
||||
// We have to set these functions instead of just declaring them because
|
||||
// paper.js tools hook up the listeners in the setter functions.
|
||||
|
|
Loading…
Reference in a new issue