The Menu Library and Esc key

The Prompt block from the Menu Library does not allow checking for the Esc key. The related “answer“ reporter does not have the “clear answer“ block. It would help to catch when the user cancels the selection.

it has nothing to do with the library, it’s just that snap treats the esc key as canceling the ask.

key (join [esc]$<:>) pressed?

You can kind of do that with

ask <<false>> and wait //Terminates all ask processes, resets the answer\

There is no built-in “cancel” option. However if you add one yourself

prompt [choose!] options [1] [cancel] $<:> ::sensing reporter

And then detect if it equals “cancel”

I think the OP was talking about how pressing esc when something is being asked cancels the ask.

Oh. That doesn’t happen to me…

Video please?

You don’t see me pressing esc, but I am.

ezgif-43dde265cea17485

Escape will first unselect the text box (so you aren’t writing in there) and clear it. If pressed again or without clicking on the text box first while in edit mode (not presentation mode), it will terminate the ask completely.

It might be that I was not clear. Imagine this situation. There are two prompt blocks (from the Menus library), one after another. The user selects something in the first block (the reporter would show a valid selection). The second prompt would be Esc terminated by the user, but the reporter (and the “answer“ block) would still contain the first selected option. It looks like there is no way to clear the “answer“content. I am not experienced with the Snap yet, but I would expect this behaviour. When the Esc key terminates the prompt (even a nested one), the reporter would return something like “Esc“, “Nothing“,…

At least for me, pressing the esc key in the editor actually stops the project entirely, so yes, it does cancel the prompt, but it also stops all running scripts. Meaning that it won’t actually continue your script if the user pressed esc. However, pressing esc does nothing when I am in presentation mode, as in, it does not close the prompt and all scripts still run as normal.

Just checked and I get the same behaviour.

I used it on the text box…

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.