How to Cancel a Wait Command

I was wondering if anyone could tell me how to stop a wait command from firing even after hiding the dynamic panel.
To elaborate further; I have a dialog that I fire on command that has a 5 second wait timer followed by an show command, so the experience is I click a button that fires the dialog and the dialog waits 5 seconds then triggers the “Open” command which is an open page. However, I have a cancel button that when the user clicks it the dialog closes and then hides that dialog and opens another one. Unfortunately this does not stop the wait command from firing because each panel is in the same page and the first dialog is just hidden.

Hi!

Rather than using Wait, you can create a timer of sorts - one that you can cancel.

  • Create a dynamic panel called ‘timer’ with blank states State1 through State10

  • Add the following code to this panel

    OnPanelStateChange
      if State of This equals State10
        Set This to State1
        Open page in current window (or whatever you want to do when time is up)
    
  • On the command that shows the dialog, add the following code

    OnClick (or whatever)
      Set timer to Next repeat every 500ms delay first change
      Show dialog
    
  • So this will cause the timer to tick through its 10 states every half second, and as you see further above, when it hits State10, it will do the desired action.

  • To cancel the timer (lets say, with a button in the dialog):

    OnClick
      Set timer to Stop Repeating
      Set timer to State1
      hide dialog
    

Example: stop_wait.rp (72.3 KB)

4 Likes

Another option is to do a test at the end of the ‘wait’ to see if the show has been cancelled in the meantime.

You could use a global variable: IsDialogShowCancelled with a default value of False.
If the Cancel button is pressed, set the variable to True.
When the wait finishes, trigger a command that checks if the cancel button has been pressed before showing the dialog.

Example: Cancel timer example.rp (50.1 KB)

Oops, I just noticed that this was posted in Axure 8, and my example is an Axure 9 file. Let me know if you need me to make an Axure 8 version.

3 Likes

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