mirror of
https://github.com/scratchfoundation/scratch-vm.git
synced 2024-12-23 14:32:59 -05:00
Pass through block drag event
This commit is contained in:
parent
8e1719b716
commit
fe4b3d3c01
3 changed files with 30 additions and 0 deletions
|
@ -288,6 +288,16 @@ class Blocks {
|
|||
newCoordinate: e.newCoordinate
|
||||
});
|
||||
break;
|
||||
case 'drag':
|
||||
if (optRuntime) {
|
||||
optRuntime.emitBlockDragUpdate(e.isOutside);
|
||||
}
|
||||
break;
|
||||
case 'endDrag':
|
||||
if (optRuntime) {
|
||||
optRuntime.emitBlockDragUpdate(false /* areBlocksOverGui */);
|
||||
}
|
||||
break;
|
||||
case 'delete':
|
||||
// Don't accept delete events for missing blocks,
|
||||
// or shadow blocks being obscured.
|
||||
|
|
|
@ -379,6 +379,15 @@ class Runtime extends EventEmitter {
|
|||
return 'MONITORS_UPDATE';
|
||||
}
|
||||
|
||||
/**
|
||||
* Event name for block drag update.
|
||||
* @const {string}
|
||||
*/
|
||||
static get BLOCK_DRAG_UPDATE () {
|
||||
return 'BLOCK_DRAG_UPDATE';
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Event name for reporting that an extension was added.
|
||||
* @const {string}
|
||||
|
@ -1387,6 +1396,14 @@ class Runtime extends EventEmitter {
|
|||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Emit whether blocks are being dragged over gui
|
||||
* @param {boolean} areBlocksOverGui True if blocks are dragged out of blocks workspace, false otherwise
|
||||
*/
|
||||
emitBlockDragUpdate (areBlocksOverGui) {
|
||||
this.emit(Runtime.BLOCK_DRAG_UPDATE, areBlocksOverGui);
|
||||
}
|
||||
|
||||
/**
|
||||
* Emit value for reporter to show in the blocks.
|
||||
* @param {string} blockId ID for the block.
|
||||
|
|
|
@ -74,6 +74,9 @@ class VirtualMachine extends EventEmitter {
|
|||
this.runtime.on(Runtime.MONITORS_UPDATE, monitorList => {
|
||||
this.emit(Runtime.MONITORS_UPDATE, monitorList);
|
||||
});
|
||||
this.runtime.on(Runtime.BLOCK_DRAG_UPDATE, areBlocksOverGui => {
|
||||
this.emit(Runtime.BLOCK_DRAG_UPDATE, areBlocksOverGui);
|
||||
});
|
||||
this.runtime.on(Runtime.EXTENSION_ADDED, blocksInfo => {
|
||||
this.emit(Runtime.EXTENSION_ADDED, blocksInfo);
|
||||
});
|
||||
|
|
Loading…
Reference in a new issue