Re: intercept nervous button clicks...

Let me sum up:
* In the beginning of each button click callback you call a
function to make the buttons insensitive (even the clicked one?
protection is needed here also),

I just kept a list of all the buttons that mattered, and insensitised them all rather indiscriminantly (even 
the clicked one) in a loop.  As someone else mentioned, you could try insensitising the whole window; I still 
wanted to keep some of the widgets active.

* in the end of each button click event you start an idle function
(by the way do you start the same idle function for all buttons? if
so, how did you make sure to not start it twice?)

It shouldn't be able to start twice.  The idle function was started from the same function that insensitised 
all the buttons, and it was only those buttons' click handlers that called it.  So once one triggered it, 
they were all rendered insensitive until it was over.

Even so, I did keep the id of the idle function as a global, though you could stash it in the window object 
or something.  The idle callback set the ID to an invalid value, and then re-sensitised everything and 
removed itself.

* the idle function make the buttons sensitive again after a

An idle timeout should do it, assuming Windows delivers the clicks as fast as the app will take them.  
Otherwise make the user wait half a second, or maybe even a full second.

It's dodgy, but then so is the reason you're having the problem in the first place.  ;)  You could also try 
waiting until the idle callback has been called a couple thousand times.  The only "correct" solution I can 
really see, would be to make the idle callback check to see if there's any more mouse clicks in the message 
queue, if that's possible without a large amount of pain and suffering.

* the idle function is killed when the program exits

Insensitise the buttons as soon as possible, start your processing, then when it's done, we start some kind 
of timeout to soak up all those damn mouse clicks.  The idea is that the idle timeout shouldn't trigger while 
there are events comming in.  At least, that was always my impression of what "idle" means.  ;)  Seemes to 
work on my system.  My swap partition is on a hard drive that I don't often use for anything else, so it 
sometimes gets to spin down, causing the whole system to stop for a second or two while it spins up again so 
the virtual memory system can do its thing.  It seemed to work fine there...

Did I get you right?

Sure...  Give it a shot, and let us know how you went.  Insensitising things is the "proper" way to indicate 
they're not supposed to be used right now, and this way it uses the built in mechansism to eat the excessive 
mouse clicks.

Hopefully I haven't forgotten anything.  ;)


Join Excite! -
The most personalized portal on the Web!

[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]