Re: changing a widgets callback function runtime

From: Date: Sat, 11 Jan 2003 06:13:49 +0000
Subject: Re: changing a widgets callback function runtime
References: 1 2  Groups: php.gtk.general 
Request: Send a blank email to php-gtk-general+get-2885@lists.php.net to get a copy of this message
you assume that I have a clue what I am trying to say :) sorry..... I have a button connected to a function like so function say_hello(){ echo 'hello'; } $but=&new GtkButton('hello'); $but->connect('clicked','say_hello'); $something->add($but); and thats fine for most of the script which says 'hello' a lot. but once or twice in the script I want to connect that buttons clicked signal to a different callback eg say_goodbye() instead of say_hello() I have plenty of ways around this ... eg setting a flag or variable then... function say_hello(){ global $flag; if($flag){ echo 'hello'; }else{ echo 'toodle-pip!'; } } but to avoid this (and other methods) I wondered if I could programatically tell $button that now it has to call say_goodbye() when clicked instead of say_hello() ? so change its callback for the 'clicked 'signal to a new function. I started looking at the gtkobject->get & set_args() in the GTK manual but not sure if I am even warm looking there ? I hope that makes more sense? Regards, Simon. ----- Original Message ----- From: "Steph" <sfox@php.net> To: "firepage" <firepage@firepages.org>; <php-gtk-general@lists.php.net> Sent: Saturday, January 11, 2003 1:32 PM Subject: Re: [PHP-GTK] changing a widgets callbck function runtime > I don't think I'm alone in thinking 'huh?' here > > Can you be a bit more gentle with your explanations pls? :) > > ----- Original Message ----- > From: "firepage" <firepage@firepages.org> > To: <php-gtk-general@lists.php.net> > Sent: Saturday, January 11, 2003 5:26 AM > Subject: [PHP-GTK] changing a widgets callbck function runtime > > > Hi, > > Is it possible to change the callback for a widgets signal after it has > been set? eg if I > > $button->connect('clicked',callback); > > can I later override that default 'clicked' callback? I am currently > setting flags onclick and then running a switch inside the function but > if I could change the callback it would be nice and lose a lot of > variable baggage. > > Regards, > Simon. > > > > > > >

« previous php.gtk.general (#2885) next »