Re: SpinButton too sensitive (SOLVED)



sÃn 2010-05-23 klockan 23:22 +1000 skrev Dan:
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

This had no effect.

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

Doing this with a timeout of 1 millisecond (the smallest possible value)
makes the problem worse as one mouse click now causes even more than two
increments. Setting it to 2 or more msecs solves the problem for normal
mouse clicks, but the behaviour is still strange if I keep the mouse
button pressed because the value is not updating on the screen until you
release the mouse button, so you get no feeling for how much you are
increasing the value when you keep the mouse button pressed.

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

This also solves the problem, and without the problem caused by the
Timeout method, so this seems to be the best solution. The Idle function
is typically not called until the mouse button is released, and then it
is called as many times as the value was incremented. In my case, I only
need it to be called once, even if the value was incremented many times,
so I now use this scheme:

$filter_rating->signal_connect(value_changed => sub {
    $filter_rating_update_needed = TRUE;
    Glib::Idle->add(sub {
        return unless $filter_rating_update_needed;
        # DO TIME CONSUMING STUFF HERE
        $filter_rating_update_needed = FALSE;
        return FALSE;
    });
    return FALSE;
});

Thanks for the help!

/Pelle




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