diff --git a/HISTORY.md b/HISTORY.md index 7a729e68..c9d161c7 100755 --- a/HISTORY.md +++ b/HISTORY.md @@ -4,7 +4,7 @@ * **New Features:** * passing a list to the ASK command in sensing presents a menu to the user * formatting a list of texts displays it as chat-history in an ASK menu - * ASK nothing or a falsy value terminates the thread currently displaying a question + * ASK nothing or a falsy value terminates all threads currently displaying a question or waiting to ask one * new "Menus" library * export script (including dependencies) via its context menu * export / import sprite-local custom block definitions from the palette @@ -40,6 +40,9 @@ * **Translation Updates:** * German +### 2022-04-20 +* threads: terminate all threads waiting to display a question on ASKing a falsy value + ### 2022-04-19 * threads: ASK nothing or a falsy value terminates the thread currently displaying a question diff --git a/snap.html b/snap.html index 52e05ccc..d10cdb8b 100755 --- a/snap.html +++ b/snap.html @@ -17,7 +17,7 @@ - + diff --git a/src/threads.js b/src/threads.js index b9a871be..87ce860d 100644 --- a/src/threads.js +++ b/src/threads.js @@ -63,9 +63,9 @@ TableFrameMorph, ColorSlotMorph, isSnapObject, newCanvas, Symbol, SVG_Costume, SnapExtensions, AlignmentMorph, TextMorph, Cloud, HatBlockMorph, StagePickerMorph*/ -/*jshint esversion: 6, bitwise: false, evil: true*/ +/*jshint esversion: 11, bitwise: false, evil: true*/ -modules.threads = '2022-April-19'; +modules.threads = '2022-April-20'; var ThreadManager; var Process; @@ -3647,6 +3647,15 @@ Process.prototype.doAsk = function (data) { rightSpace; stage.keysPressed = {}; + if (!data) { + // terminate all other processes currently asking a question + // or waiting to ask one + stage.threads.processes.filter(proc => + (proc.prompter && !proc.prompter.isDone) || + (proc?.context?.expression?.selector === 'doAsk' && proc !== this) + ).forEach(proc => proc.stop()); + return; + } if (!this.prompter) { activePrompter = detect( stage.children, @@ -3699,13 +3708,6 @@ Process.prototype.doAsk = function (data) { this.prompter.inputField.edit(); stage.changed(); } - } else if (!data) { - // terminate the processes currently asking a question - // making way for the next one waiting to ask one - stage.threads.processes.filter(proc => - proc.prompter && !proc.prompter.isDone - ).forEach(proc => proc.stop()); - return; } } else { if (this.prompter.isDone) {