icza / gowut

Go Web UI Toolkit - Public Releases and Development
GNU General Public License v3.0
300 stars 35 forks source link

Disable Components While Their Event is Processed #31

Open ddrake12 opened 7 years ago

ddrake12 commented 7 years ago

For long running actions, it would be helpful to have a built-in way to disable components while their event is processed. For example, currently the user could press a button multiple times while the first long running action is happening creating successive events using the same selections on the GUI.

I have used the following workaround for a button (which can be extended for other components/paradigms):

Use a timer to continually call MarkDirty() on the button, then on the button click event run a long running action in a goroutine (which will return immediately). Calls to SetEnabled() within the goroutine will be updated as quickly as the timer repeats..

powerslacker commented 5 years ago

Don't mean to resurrect the dead here -- but you could use a sync.Mutex to lock the button down, so multiple presses would have no effect.