in reply to How to freeze a button while it is in active mode
It partly depends upon exactly what your graphic user-interface is set up to do (and how much support for, e.g., “button groups” you have at your disposal with any particular platform), but here is a general strategy for the handler for a button that will take a little while to complete. (Entirely-abstract non-Perl pseudocode):
Translating that to “Perl or what-have-you” I leave as an exercise to the reader. The try..finally construct that I refer to (which doesn’t automatically exist in Perl) is one that will always execute the finally portion even if an exception occurred.disableButton(); try { doTheWork(); } finally { enableButton(); } }
My point, in using it, is that you always have to anticipate and to handle exceptions that may occur in your button-handler, so that you always re-enable the button.
Some GUIs provide for button-groups which simply means that the outer-level framework takes care of enabling and disabling the buttons.
Likewise, some GUIs implement buttons as objects that automatically handle the disable/enable logic (and exception-trapping), calling an onClick method of some kind to doTheWork().
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: How to freeze a button while it is in active mode
by SuicideJunkie (Vicar) on Jul 17, 2014 at 19:31 UTC | |
|
Re^2: How to freeze a button while it is in active mode
by Janish (Sexton) on Jul 18, 2014 at 02:41 UTC |