Add setDragMode primitive and unit test

This commit is contained in:
Paul Kaplan 2017-12-28 12:31:23 -05:00
parent 9d5bbdbf3a
commit d001a85571
2 changed files with 19 additions and 0 deletions

View file

@ -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');
}

View file

@ -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();
});