kopia lustrzana https://github.com/backface/turtlestitch
trigger "When I am stopped" when programmatically calling "stop all"
rodzic
57f3a849b6
commit
7478f6039f
|
|
@ -4137,3 +4137,7 @@ in development:
|
||||||
------
|
------
|
||||||
* Blocks, Objects: new experimental "When I am stopped" event option
|
* Blocks, Objects: new experimental "When I am stopped" event option
|
||||||
* Threads: Prevent terminated threads from forking new ones and from cloning
|
* Threads: Prevent terminated threads from forking new ones and from cloning
|
||||||
|
|
||||||
|
180609
|
||||||
|
------
|
||||||
|
* Objects, Threads: Also trigger "When I am stopped" when programmatically calling "stop all"
|
||||||
|
|
|
||||||
16
objects.js
16
objects.js
|
|
@ -83,7 +83,7 @@ BlockEditorMorph, BlockDialogMorph, PrototypeHatBlockMorph, localize,
|
||||||
TableMorph, TableFrameMorph, normalizeCanvas, BooleanSlotMorph, HandleMorph,
|
TableMorph, TableFrameMorph, normalizeCanvas, BooleanSlotMorph, HandleMorph,
|
||||||
AlignmentMorph, Process, XML_Element, VectorPaintEditorMorph*/
|
AlignmentMorph, Process, XML_Element, VectorPaintEditorMorph*/
|
||||||
|
|
||||||
modules.objects = '2018-June-08';
|
modules.objects = '2018-June-09';
|
||||||
|
|
||||||
var SpriteMorph;
|
var SpriteMorph;
|
||||||
var StageMorph;
|
var StageMorph;
|
||||||
|
|
@ -4855,7 +4855,11 @@ SpriteMorph.prototype.mouseScroll = function (y) {
|
||||||
return this.receiveUserInteraction('scrolled-' + (y > 0 ? 'up' : 'down'));
|
return this.receiveUserInteraction('scrolled-' + (y > 0 ? 'up' : 'down'));
|
||||||
};
|
};
|
||||||
|
|
||||||
SpriteMorph.prototype.receiveUserInteraction = function (interaction, now) {
|
SpriteMorph.prototype.receiveUserInteraction = function (
|
||||||
|
interaction,
|
||||||
|
rightAway,
|
||||||
|
threadSafe
|
||||||
|
) {
|
||||||
var stage = this.parentThatIsA(StageMorph),
|
var stage = this.parentThatIsA(StageMorph),
|
||||||
procs = [],
|
procs = [],
|
||||||
myself = this,
|
myself = this,
|
||||||
|
|
@ -4866,11 +4870,11 @@ SpriteMorph.prototype.receiveUserInteraction = function (interaction, now) {
|
||||||
procs.push(stage.threads.startProcess(
|
procs.push(stage.threads.startProcess(
|
||||||
block,
|
block,
|
||||||
myself,
|
myself,
|
||||||
stage.isThreadSafe,
|
threadSafe || stage.isThreadSafe,
|
||||||
null, // export result
|
null, // export result
|
||||||
null, // callback
|
null, // callback
|
||||||
null, // is clicked
|
null, // is clicked
|
||||||
now // immediately
|
rightAway // immediately
|
||||||
));
|
));
|
||||||
});
|
});
|
||||||
return procs;
|
return procs;
|
||||||
|
|
@ -6961,10 +6965,10 @@ StageMorph.prototype.fireStopAllEvent = function () {
|
||||||
StageMorph.prototype.runStopScripts = function () {
|
StageMorph.prototype.runStopScripts = function () {
|
||||||
// experimental: Allow each sprite to run one last step before termination
|
// experimental: Allow each sprite to run one last step before termination
|
||||||
// usage example: Stop a robot or device associated with the sprite
|
// usage example: Stop a robot or device associated with the sprite
|
||||||
this.receiveUserInteraction('stopped', true);
|
this.receiveUserInteraction('stopped', true, true);
|
||||||
this.children.forEach(function (morph) {
|
this.children.forEach(function (morph) {
|
||||||
if (morph instanceof SpriteMorph) {
|
if (morph instanceof SpriteMorph) {
|
||||||
morph.receiveUserInteraction('stopped', true);
|
morph.receiveUserInteraction('stopped', true, true);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
|
||||||
|
|
@ -62,7 +62,7 @@ StageMorph, SpriteMorph, StagePrompterMorph, Note, modules, isString, copy,
|
||||||
isNil, WatcherMorph, List, ListWatcherMorph, alert, console, TableMorph,
|
isNil, WatcherMorph, List, ListWatcherMorph, alert, console, TableMorph,
|
||||||
TableFrameMorph, ColorSlotMorph, isSnapObject*/
|
TableFrameMorph, ColorSlotMorph, isSnapObject*/
|
||||||
|
|
||||||
modules.threads = '2018-May-08';
|
modules.threads = '2018-June-09';
|
||||||
|
|
||||||
var ThreadManager;
|
var ThreadManager;
|
||||||
var Process;
|
var Process;
|
||||||
|
|
@ -1854,6 +1854,7 @@ Process.prototype.doStopAll = function () {
|
||||||
if (stage) {
|
if (stage) {
|
||||||
stage.threads.resumeAll(stage);
|
stage.threads.resumeAll(stage);
|
||||||
stage.keysPressed = {};
|
stage.keysPressed = {};
|
||||||
|
stage.runStopScripts();
|
||||||
stage.threads.stopAll();
|
stage.threads.stopAll();
|
||||||
stage.stopAllActiveSounds();
|
stage.stopAllActiveSounds();
|
||||||
stage.children.forEach(function (morph) {
|
stage.children.forEach(function (morph) {
|
||||||
|
|
|
||||||
Ładowanie…
Reference in New Issue