Re: SpinButton too sensitive



On Sat, 2010-05-22 at 15:18 +0200, Pelle Nilsson wrote:

Hi

I have a SpinButton in my app with a function connected to the
value_changed signal that takes some time (about 1 second) to execute.
This has the unwanted effect that when I press the increment-button in
the SpinButton, it increments twice. Somehow it seems that Gtk thinks
that the mouse button is pressed for longer than it is because the
callback function takes a long time to execute. How can I prevent this?

/Pelle

I've seen this too. It's been a while since I did any Gtk2 programming,
but try these ideas ( one at a time ).

- use signal_connect_after instead of signal_connect

- don't execute the code immediately, but set up a timer
( Glib::Timeout ) to execute the code slightly after the spinbutton is
changed

- as above, but execute the code in Gtk2 'idle' time, eg
Glib::Idle->add( sub { ... } );

My understanding of Gtk2 is kinda limited ( I get by ), but my
impression when I hit this was that if the code took too long to
execute, Gtk2 wouldn't see the mouse being released quickly enough, and
would think you'd held it down enough to spin more than one ... thingy.

Let me know which one, if any, fixes this :)

Dan




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