mirror of
https://github.com/scratchfoundation/scratch-vm.git
synced 2024-12-25 07:22:33 -05:00
Activate stage click hats if no other clicks are hit.
Also check the bounds before to make sure clicks are inside the stage bounds.
This commit is contained in:
parent
c36ff056a2
commit
978906d926
1 changed files with 10 additions and 1 deletions
|
@ -44,6 +44,12 @@ class Mouse {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
// If haven't returned, activate click hats for stage.
|
||||||
|
// Still using both blocks for sharing compatibility.
|
||||||
|
this.runtime.startHats('event_whenthisspriteclicked',
|
||||||
|
null, this.runtime.getTargetForStage());
|
||||||
|
this.runtime.startHats('event_whenstageclicked',
|
||||||
|
null, this.runtime.getTargetForStage());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -70,7 +76,10 @@ class Mouse {
|
||||||
}
|
}
|
||||||
if (typeof data.isDown !== 'undefined') {
|
if (typeof data.isDown !== 'undefined') {
|
||||||
this._isDown = data.isDown;
|
this._isDown = data.isDown;
|
||||||
if (!this._isDown) {
|
// Make sure click is within the canvas bounds to activate click hats
|
||||||
|
if (!this._isDown &&
|
||||||
|
data.x > 0 && data.x < data.canvasWidth &&
|
||||||
|
data.y > 0 && data.y < data.canvasHeight) {
|
||||||
this._activateClickHats(data.x, data.y, data.wasDragged);
|
this._activateClickHats(data.x, data.y, data.wasDragged);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue