Disabling a Button During an Event

21 views
Skip to first unread message

Dave Drake

unread,
Apr 27, 2017, 12:07:16 PM4/27/17
to gowebuitoolkit
Hi,

First off, I love gowut, it's really good for my current projects. I am wondering how I might go about disabling a button during an event? For long running actions, this would be very helpful because currently the user can press the button multiple times while the first long running action is happening which creates successive events using the same selections on the GUI. I can't think of a good way to approach this since I can't programmatically send an event (to say an invisible disabled button) even with a timer. Do you have any recommendations?

I could submit an enhancement request if you'd like.

Thanks!
Dave

András Belicza

unread,
Apr 28, 2017, 12:24:31 AM4/28/17
to Dave Drake, gowebuitoolkit
Good question.

Events are sent in a synchronous mode, so until a handler returns, the client won't send more events.

So in the current version maybe you can manage at server side that handling the request was done between timestamps t1 and t2, and if a new event arrives from the client that has t3 timestamp which is less than t2, simply don't act on it.

Yes, disabling components while their event is processed could be a good enhancement, file an enhancement issue if you feel like it.

Thanks.

Dave Drake

unread,
Apr 28, 2017, 5:48:17 PM4/28/17
to András Belicza, gowebuitoolkit
Good to know. Yeah I could do something on the other side, thanks for the suggestion and response!

Dave

Dave Drake

unread,
May 8, 2017, 11:45:27 AM5/8/17
to András Belicza, gowebuitoolkit
For everyone's knowledge, I ended up solving this problem using a timer to "constantly" call MarkDirty() on the button and running the long running action in a goroutine. This way, the button click returns immediately and calls to SetEnabled within the goroutine on the button update as quickly as the timer repeats.

I also used a similar paradigm (except with a variable) to keep a status updated while multiple successive long running actions were performed from that same button click. 
Reply all
Reply to author
Forward
0 new messages