mirror of
https://github.com/scratchfoundation/scratch-vm.git
synced 2025-08-28 22:30:40 -04:00
Add setDragMode primitive and unit test
This commit is contained in:
parent
9d5bbdbf3a
commit
d001a85571
2 changed files with 19 additions and 0 deletions
|
@ -40,6 +40,7 @@ class Scratch3SensingBlocks {
|
|||
sensing_of: this.getAttributeOf,
|
||||
sensing_mousex: this.getMouseX,
|
||||
sensing_mousey: this.getMouseY,
|
||||
sensing_setdragmode: this.setDragMode,
|
||||
sensing_mousedown: this.getMouseDown,
|
||||
sensing_keypressed: this.getKeyPressed,
|
||||
sensing_current: this.current,
|
||||
|
@ -162,6 +163,10 @@ class Scratch3SensingBlocks {
|
|||
return Math.sqrt((dx * dx) + (dy * dy));
|
||||
}
|
||||
|
||||
setDragMode (args, util) {
|
||||
util.target.draggable = args.DRAG_MODE === 'draggable';
|
||||
}
|
||||
|
||||
getTimer (args, util) {
|
||||
return util.ioQuery('clock', 'projectTimer');
|
||||
}
|
||||
|
|
|
@ -65,3 +65,17 @@ test('ask and answer with a visible target', t => {
|
|||
|
||||
s.askAndWait({QUESTION: expectedQuestion}, util);
|
||||
});
|
||||
|
||||
test('set drag mode', t => {
|
||||
const rt = new Runtime();
|
||||
const s = new Sensing(rt);
|
||||
const util = {target: {draggable: true}};
|
||||
|
||||
s.setDragMode({DRAG_MODE: 'not draggable'}, util);
|
||||
t.strictEqual(util.target.draggable, false);
|
||||
|
||||
s.setDragMode({DRAG_MODE: 'draggable'}, util);
|
||||
t.strictEqual(util.target.draggable, true);
|
||||
|
||||
t.end();
|
||||
});
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue