Re: Control user change of SpinButton value
- From: Paul Breeuwsma <gtkmm paulinternet nl>
- To: gtkmm-list gnome org
- Subject: Re: Control user change of SpinButton value
- Date: Sat, 15 Jul 2006 16:31:37 +0200
Josepo Urrutia wrote:
If I use the Gtk::SpinButton::signal_value_changed I can do a callback
whenever the value of a spinbutton is changed, the problem is that this
callback is also fired if the value is changed by the code not only by the
user.
Here is some code that doubles the value of the spinbutton after someone
changed it. Maybe you can use it.
#include <gtkmm.h>
void update (Gtk::SpinButton *spinbutton)
{
static bool code = false;
if(code)
{
code = false;
}
else
{
spinbutton->set_value(2.0 * spinbutton->get_value());
code = true;
}
}
int main (int argc, char **argv)
{
Gtk::Main gtk(argc, argv);
Gtk::Window window;
Gtk::SpinButton spinbutton;
spinbutton.set_range(0.0, 1000.0);
spinbutton.set_increments(1.0, 1.0);
spinbutton.signal_value_changed().connect(sigc::bind(sigc::ptr_fun(&update), &spinbutton));
window.add(spinbutton);
window.set_border_width(10);
window.show_all();
Gtk::Main::run(window);
return 0;
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]