Page 1 of 1

Using the "wait" command

Posted: Fri Feb 05, 2021 5:43 am
by PlaidFlannel
I would like to implement a kind of "alert" feature in my stack, but with three constraints.
  • I would like not to use any kind of dialog box that would obscure part of the stack window.
  • I would like the alert to be "self-dismissing".
  • I would like it not to be blocking, at least not obtrusively.
One use case is alerting the user to the fact that some interaction in one area of the card has caused the value in a field elsewhere on the card to change. My current (acceptable) technique is to change the background color of the field to yellow, wait one second, and then reset the background color to white. Because this kind of alert occurs while the user is interacting, the one second delay is not a problem

Another use case is alerting the user to things that happen during a long-running script. Is there a way to use the "yellow field" approach, possibly using a dedicated "status line" field at the bottom of the card, but without the script blocking because of the "wait" command?

Re: Using the "wait" command

Posted: Fri Feb 05, 2021 6:39 am
by Davidv
My option would be to make the alert change, then
send <<changeRevert>> to me in 1 sec
where changeRevert is the call to your reversion code. This will accomplish what you want without blocking the user. You can tune the delay by using milliseconds.

For different circumstances you might also look at "wait with messages" if you have not already. It allows other actions before continuing the current handler after the desired delay. In that case just watch out for conflicts between subsequent handler code and any other action which might be taken in the interim.

Re: Using the "wait" command

Posted: Fri Feb 05, 2021 3:44 pm
by dunbarx
Something like this?
Running Alert.livecode.zip
(1.19 KiB) Downloaded 165 times
Click on btn "start". The nature of showing and hiding the alert field is up to you. This is just an example, so check out the script of btn "start". You can click on the upper button during this process at any time. OptionKey stops this madness.

Craig