mirror of
https://github.com/scratchfoundation/scratch-vm.git
synced 2025-08-28 22:30:40 -04:00
Update the mouse io to give scratch coordinates and client coordinates
Fixes GUI #642 https://github.com/LLK/scratch-gui/issues/642 Fixes GUI #179 https://github.com/LLK/scratch-gui/issues/179
This commit is contained in:
parent
bbcb6bd5b7
commit
327d1179d9
5 changed files with 64 additions and 38 deletions
|
@ -8,10 +8,10 @@ test('spec', t => {
|
|||
|
||||
t.type(m, 'object');
|
||||
t.type(m.postData, 'function');
|
||||
t.type(m.getX, 'function');
|
||||
t.type(m.getY, 'function');
|
||||
t.type(m.getClampedX, 'function');
|
||||
t.type(m.getClampedY, 'function');
|
||||
t.type(m.getClientX, 'function');
|
||||
t.type(m.getClientY, 'function');
|
||||
t.type(m.getScratchX, 'function');
|
||||
t.type(m.getScratchY, 'function');
|
||||
t.type(m.getIsDown, 'function');
|
||||
t.end();
|
||||
});
|
||||
|
@ -27,10 +27,10 @@ test('mouseUp', t => {
|
|||
canvasWidth: 480,
|
||||
canvasHeight: 360
|
||||
});
|
||||
t.strictEquals(m.getX(), -260);
|
||||
t.strictEquals(m.getY(), 170);
|
||||
t.strictEquals(m.getClampedX(), -240);
|
||||
t.strictEquals(m.getClampedY(), 170);
|
||||
t.strictEquals(m.getClientX(), -20);
|
||||
t.strictEquals(m.getClientY(), 10);
|
||||
t.strictEquals(m.getScratchX(), -240);
|
||||
t.strictEquals(m.getScratchY(), 170);
|
||||
t.strictEquals(m.getIsDown(), false);
|
||||
t.end();
|
||||
});
|
||||
|
@ -46,10 +46,27 @@ test('mouseDown', t => {
|
|||
canvasWidth: 480,
|
||||
canvasHeight: 360
|
||||
});
|
||||
t.strictEquals(m.getX(), -230);
|
||||
t.strictEquals(m.getY(), -220);
|
||||
t.strictEquals(m.getClampedX(), -230);
|
||||
t.strictEquals(m.getClampedY(), -180);
|
||||
t.strictEquals(m.getClientX(), 10);
|
||||
t.strictEquals(m.getClientY(), 400);
|
||||
t.strictEquals(m.getScratchX(), -230);
|
||||
t.strictEquals(m.getScratchY(), -180);
|
||||
t.strictEquals(m.getIsDown(), true);
|
||||
t.end();
|
||||
});
|
||||
|
||||
test('at zoomed scale', t => {
|
||||
const rt = new Runtime();
|
||||
const m = new Mouse(rt);
|
||||
|
||||
m.postData({
|
||||
x: 240,
|
||||
y: 540,
|
||||
canvasWidth: 960,
|
||||
canvasHeight: 720
|
||||
});
|
||||
t.strictEquals(m.getClientX(), 240);
|
||||
t.strictEquals(m.getClientY(), 540);
|
||||
t.strictEquals(m.getScratchX(), -120);
|
||||
t.strictEquals(m.getScratchY(), -90);
|
||||
t.end();
|
||||
});
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue