RE: intercept nervous button clicks...




in my app some actions behind buttons take time, so the button
is released not before the action is done. This is ok.  However, I
need to prevent the user from clicking other buttons in the
meantime. The problem seems to be harder than it looks since gtk
can not empty the mouse click buffer (of ms window in my case) and
so, right when the first button is finally released the next is
pressed "automagically"...

How about clearing the button blocked flag from an idler, started once the action is complete?

And for a bit of visual feedback (always a good idea), make all the buttons insensitive (which should eat any 
extra button clicks) as soon as you recieve the clicked signal.

Of course, if you're going to be doing something which will take a while, it's always a good idea to either 
palm it off to another thread, or make sure it runs a few iterations of the main loop a couple times a second.


Fairly recently I had a button run an external program (re: that discussion a little while back about 
spawn_with_pipes).  Usually the program runs and completes very quickly, but sometimes it gets stalled 
briefly waiting for network activity.  So I add a half-second timer which starts off just what I described.  
When the timer trips it makes the more important dialog buttons insensitive (the timer gets killed if the 
program finishes before it gets called, and zeros its global timer id variable if it runs first).  Then when 
the external program finishes, a function gets called which restores the window to working order.  All I'd 
need to deal with your situation, would be to slip in an idle timeout to call the restore function instead of 
calling the restore function directly.  That's if it wasn't already solved by insensitising the buttons and 
keeping the main loop running.


Fredderic

_______________________________________________
Join Excite! - http://www.excite.com
The most personalized portal on the Web!



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