mirror of
https://github.com/scratchfoundation/scratch-vm.git
synced 2025-08-28 22:30:40 -04:00
Differentiate clamped from non clamped mouse io data (GUI#179)
This commit is contained in:
parent
980efedf0f
commit
bbcb6bd5b7
4 changed files with 38 additions and 16 deletions
|
@ -10,6 +10,8 @@ test('spec', t => {
|
|||
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.getIsDown, 'function');
|
||||
t.end();
|
||||
});
|
||||
|
@ -19,14 +21,16 @@ test('mouseUp', t => {
|
|||
const m = new Mouse(rt);
|
||||
|
||||
m.postData({
|
||||
x: 1,
|
||||
x: -20,
|
||||
y: 10,
|
||||
isDown: false,
|
||||
canvasWidth: 480,
|
||||
canvasHeight: 360
|
||||
});
|
||||
t.strictEquals(m.getX(), -239);
|
||||
t.strictEquals(m.getX(), -260);
|
||||
t.strictEquals(m.getY(), 170);
|
||||
t.strictEquals(m.getClampedX(), -240);
|
||||
t.strictEquals(m.getClampedY(), 170);
|
||||
t.strictEquals(m.getIsDown(), false);
|
||||
t.end();
|
||||
});
|
||||
|
@ -37,13 +41,15 @@ test('mouseDown', t => {
|
|||
|
||||
m.postData({
|
||||
x: 10,
|
||||
y: 100,
|
||||
y: 400,
|
||||
isDown: true,
|
||||
canvasWidth: 480,
|
||||
canvasHeight: 360
|
||||
});
|
||||
t.strictEquals(m.getX(), -230);
|
||||
t.strictEquals(m.getY(), 80);
|
||||
t.strictEquals(m.getY(), -220);
|
||||
t.strictEquals(m.getClampedX(), -230);
|
||||
t.strictEquals(m.getClampedY(), -180);
|
||||
t.strictEquals(m.getIsDown(), true);
|
||||
t.end();
|
||||
});
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue