swiftDialog icon indicating copy to clipboard operation
swiftDialog copied to clipboard

Customisation of how long button1 is disabled for when using a Timer bar

Open philipross opened this issue 1 year ago • 2 comments

Is your feature request related to a problem? Please describe. Currently I have a use case where I'm using a timer bar to countdown and dismiss a dialog if there's no user interaction, before the script continues (restarts Self Service if it's running etc). The message that I'm giving to users isn't very long, but certainly takes more than 3 seconds to read once the dialog appears, and some users could dismiss/are dismissing this without actually reading what the message says.

Describe the solution you'd like I would like to be able to customise how long the button1 is disabled for, when the parameters align to cause it to be disabled for 3 seconds.

Describe alternatives you've considered The only other option I have at the moment is to remove the button 1 completely, and force users to have the dialog remain for the full countdown. This means I've had to reduce the countdown time to shorter than I'd like, to balance either side of the coin.

Additional context

If used in conjuction with --button1text the default button will be displayed but will be disabled for the first 3 seconds of the timer, after which it becomes active and can be used to dismiss dialog with the standard button 1 exit code of 0

Perhaps an new argument of --button1durationdisabled (I appreciate that's a bit long) could be used to allow us to set this to be disabled for a custom length of time. E.g:

  dialog --ontop --title none \
    --message "Updates are required which will restart Self Service.\nThis will action when the
timer lapses, or you can press OK to continue now." \
    --icon /path/to/icon.png \
    --timer 30 \
    --moveable \
    --button1text OK \
    --button1durationdisabled 8 \
    --mini

philipross avatar Jun 14 '24 13:06 philipross

ok - that's actually a bit of a bug since --timer isn't really designed/supported in mini mode. It's a part of the button area though so it shows up.

That said, if you want more control over timer bars and when the button becomes available, you can use a regular progress bar and control the progress and button directly. Some info on that here https://github.com/swiftDialog/swiftDialog/issues/231

bartreardon avatar Jun 14 '24 13:06 bartreardon

Is there currently some way to disable the 3-second delay before button1 becomes available? If not, implementing button1durationdisabled and setting this to 0 would seem a solution. The following is a trivial example where this might be desired and where a progress bar would not work as desired.

dialog --title none --message "The computer will sleep in 10 seconds" --messagefont size=14 --button1text "Sleep" --button2text "Cancel" --width 350 --height 90 --hideicon --timer 10

peavine avatar Sep 10 '24 13:09 peavine