Roll20 uses cookies to improve your experience on our site. Cookies enable you to enjoy certain features, social sharing functionality, and tailor message and display ads to your interests on our site and others. They also help us understand how our site is being used. By continuing to use our site, you consent to our use of cookies. Update your cookie preferences .
×
Create a free account

How to detect when the user clicks Cancel?

November 05 (1 year ago)

Edited November 05 (1 year ago)
GiGs
Pro
Sheet Author
API Scripter

One thing I've been doing a lot laterly is using custom roll parsing queries, where you present a message box like this:



If someone clicks the Submit button, the code can detect which entry you selected, like so:

on('change:system_flag', (event) => {
    if (event.sourceType == 'sheetworker') return;
    startRoll("!{{template:pages}}{{ask=![[?{Are You Sure? This will erase your current character|No,0|Do It!,1}]]}}", (question) => {  
        const query = question.results.ask.result;
        if(query) {


But if the user clicks Cancel, I havent been able to figure out if any input is passed to the sheet worker. Is there anything that can be detected here?

The reason I ask is I want to UNDO something if the user cancels (in this case, the attribute change that triggered the button launch). So I want something to happen on a Cancel entry, but I can't figure out if there's a way to make that happen.


While writing this, I figured out an alternative way to do what I wanted, but I'm still curuous about the question here: can you react to the cancel click?

November 05 (1 year ago)
Scott C.
Forum Champion
Sheet Author
API Scripter
Compendium Curator

Nope, the cancel is just a silent exit as far as the sheetworker is concerned. There's no event sent.

November 05 (1 year ago)
GiGs
Pro
Sheet Author
API Scripter

That's a shame. Thanks, Scott.