Re: changing a widgets callback function runtime

From: Date: Sat, 11 Jan 2003 07:28:38 +0000
Subject: Re: changing a widgets callback function runtime
References: 1 2 3 4  Groups: php.gtk.general 
Request: Send a blank email to php-gtk-general+get-2889@lists.php.net to get a copy of this message
No php_esp.dll/so yet ?... I am dissapointed but anyway :p It goes like this, the button in question is 1 of a set of 3 , when 1 of these buttons is selected it toggles (they aint toggle buttons though) the other 2 , disabling them [$but->set_state(GTK_STATE_INSENSITIVE);] so only the button that has been clicked is active. so far I think I make sense ;) when this button is clicked it changes its label to 'reset' , the plan being that clicking 'reset' will 're-activate' the other 2 buttons and change its own label back to its original (pre -'reset') label. OK now I am talking gibberish but since you got this far ... basically I want to call this non-existant method.. $widget->change_callback('new_callback'); $button has callback of functionA() $button is clicked - changes its callback to functionB() $button is clicked again - changes its callback to functionA() thus toggling the functions. other events elsewhere in the window need also the ability to toggle the button states (and callback functions) errr sadly thats the best explanation I can come up with... 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 2:48 PM Subject: Re: [PHP-GTK] changing a widgets callback function runtime > kind of ...... no you're way off track with set_args(), that's about > properties basically. > > When you say 'once in a while' .. how's the button supposed to know when > that once in a while comes? Are there other indicators? Is there > timing? - because basically, unless I've misunderstood what you're > saying extremely badly, you're asking for a button with ESP, and afaik > Andrei hasn't gotten around to implementing that extension just yet.. > > Given history, I suspect I'm misunderstanding extremely badly :-\ > > ----- Original Message ----- > From: "firepage" <firepage@firepages.org> > To: "Steph" <sfox@php.net>; <php-gtk-general@lists.php.net> > Sent: Saturday, January 11, 2003 6:13 AM > Subject: Re: [PHP-GTK] changing a widgets callback function runtime > > > > 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. > > > > > > > > > > > > > > > > > > > > > > > > > > > > > -- > > PHP-GTK General Mailing List (http://gtk.php.net/) > > To unsubscribe, visit: http://www.php.net/unsub.php > > > > > >

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