terminate all threads waiting to display a question on ASKing a falsy value

snap8
Jens Mönig 2022-04-20 10:06:34 +02:00
rodzic fa3adfa189
commit fe38e085ef
3 zmienionych plików z 16 dodań i 11 usunięć

Wyświetl plik

@ -4,7 +4,7 @@
* **New Features:** * **New Features:**
* passing a list to the ASK command in sensing presents a menu to the user * 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 * 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 * new "Menus" library
* export script (including dependencies) via its context menu * export script (including dependencies) via its context menu
* export / import sprite-local custom block definitions from the palette * export / import sprite-local custom block definitions from the palette
@ -40,6 +40,9 @@
* **Translation Updates:** * **Translation Updates:**
* German * German
### 2022-04-20
* threads: terminate all threads waiting to display a question on ASKing a falsy value
### 2022-04-19 ### 2022-04-19
* threads: ASK nothing or a falsy value terminates the thread currently displaying a question * threads: ASK nothing or a falsy value terminates the thread currently displaying a question

Wyświetl plik

@ -17,7 +17,7 @@
<script src="src/symbols.js?version=2021-03-03"></script> <script src="src/symbols.js?version=2021-03-03"></script>
<script src="src/widgets.js?version=2021-17-09"></script> <script src="src/widgets.js?version=2021-17-09"></script>
<script src="src/blocks.js?version=2022-04-08"></script> <script src="src/blocks.js?version=2022-04-08"></script>
<script src="src/threads.js?version=2022-04-19"></script> <script src="src/threads.js?version=2022-04-20"></script>
<script src="src/objects.js?version=2022-04-04"></script> <script src="src/objects.js?version=2022-04-04"></script>
<script src="src/scenes.js?version=2022-03-03"></script> <script src="src/scenes.js?version=2022-03-03"></script>
<script src="src/gui.js?version=2022-04-06"></script> <script src="src/gui.js?version=2022-04-06"></script>

Wyświetl plik

@ -63,9 +63,9 @@ TableFrameMorph, ColorSlotMorph, isSnapObject, newCanvas, Symbol, SVG_Costume,
SnapExtensions, AlignmentMorph, TextMorph, Cloud, HatBlockMorph, SnapExtensions, AlignmentMorph, TextMorph, Cloud, HatBlockMorph,
StagePickerMorph*/ 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 ThreadManager;
var Process; var Process;
@ -3647,6 +3647,15 @@ Process.prototype.doAsk = function (data) {
rightSpace; rightSpace;
stage.keysPressed = {}; 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) { if (!this.prompter) {
activePrompter = detect( activePrompter = detect(
stage.children, stage.children,
@ -3699,13 +3708,6 @@ Process.prototype.doAsk = function (data) {
this.prompter.inputField.edit(); this.prompter.inputField.edit();
stage.changed(); 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 { } else {
if (this.prompter.isDone) { if (this.prompter.isDone) {