mirror of
https://github.com/scratchfoundation/scratch-vm.git
synced 2025-06-26 22:30:27 -04:00
Merge pull request #1041 from paulkaplan/fix-clone-drag
Only select the original target after a drag.
This commit is contained in:
commit
f23b5a9625
2 changed files with 29 additions and 1 deletions
|
@ -921,7 +921,8 @@ class VirtualMachine extends EventEmitter {
|
|||
if (target) {
|
||||
this._dragTarget = null;
|
||||
target.stopDrag();
|
||||
this.setEditingTarget(target.id);
|
||||
this.setEditingTarget(target.sprite && target.sprite.clones[0] ?
|
||||
target.sprite.clones[0].id : target.id);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -379,3 +379,30 @@ test('drag IO redirect', t => {
|
|||
t.equal(sprite2Info[1], 'sprite2 info 2');
|
||||
t.end();
|
||||
});
|
||||
|
||||
test('select original after dragging clone', t => {
|
||||
const vm = new VirtualMachine();
|
||||
let newEditingTargetId = null;
|
||||
vm.setEditingTarget = id => {
|
||||
newEditingTargetId = id;
|
||||
};
|
||||
vm.runtime.targets = [
|
||||
{
|
||||
id: 'sprite1_clone',
|
||||
sprite: {clones: [{id: 'sprite1_original'}]},
|
||||
stopDrag: () => {}
|
||||
}, {
|
||||
id: 'sprite2',
|
||||
stopDrag: () => {}
|
||||
}
|
||||
];
|
||||
|
||||
// Stop drag on a bare target selects that target
|
||||
vm.stopDrag('sprite2');
|
||||
t.equal(newEditingTargetId, 'sprite2');
|
||||
|
||||
// Stop drag on target with parent sprite selects the 0th clone of that sprite
|
||||
vm.stopDrag('sprite1_clone');
|
||||
t.equal(newEditingTargetId, 'sprite1_original');
|
||||
t.end();
|
||||
});
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue