Re: [gtk-list] Spin button problem




On Wed, 30 Sep 1998, Robert M. Muth wrote:
> 
> The problem is that the hiding/showing of these button apparently
> takes so long that the spin button will have triggered a new
> "value_changed" signal by the time I am done.
> This means that an attempt to increment the spin button value by 1 will
> actually increment it by say 4.
> 

That doesn't make sense to me - you should only get value_changed once per
value change. So if the user clicks once, it should increment once. Maybe
you have the step_size in the adjustment wrong?

In general a good solution for getting input too fast is to queue your
button matrix update rather than doing it immediately. That is, write an
idle function that updates the button matrix. Then keep a flag
idle_function_installed; when the spin button changes, run:

if (!idle_function_installed) {
  /* install your idle function */
}
else /* do nothing, update already pending */

When your idle function finished it should update itself and flip the
idle_function_installed flag.

Then you will only get one update per continuous series of events. If
that's still too many updates, you can use a timeout instead of an idle,
so you update only once anytime there are multiple events in the same
small timeslice. 

HTH,
Havoc




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