Re: Button How to intercept signal from a istance of classinto another class
I think you have not understood
It is not possible use this sintax parent::OneFunction(); because the mybuttons doesn't extends mywin class at this moment I use one method that find parent window for button
As the first class (mywin) is not the parent class of the second class
(mybuttons), it does not make sense to call parent::... as you have
The right way to do that is to pass the callback signature of the first
method (OneFunction) as an attribute of the mybuttons object OR create a
method in mybuttons class to receive this signature (the same way the
connect() method works).
The simplest way is:
$three_buttons = new mybuttons();
$three_buttons->my_callback = array($this, 'OneFunction');
This way, you have stored this callback inside the $three_buttons
object. But remember the ENCAPSULATION principles... It's better to
create a method to receive this... ;-)
Now, you can use the property my_callback inside the OnClose() method,
But take care with this. If you need $this->my_callback available in the
constructor method of the mybuttons class, you'll need to pass the
callback signature in its constructor method. Because the way I told
you, this signature will be available just before the instantiation...
I hope it's usefull for you.
Em Qua, 2008-10-29 às 02:31 -0700, AngeloP escreveu:
> I have a main window class
> class mywin extends GtkWindow
> // Button section
> $three_buttons = new mybuttons()
> $vbox -> pack_start($three_buttons,0);
> ...... ..etc...
> end constructor
> function OneFunction()
> make something
> class mybuttons extends GtkHbox
> .... constructor
> $button_a=new GtkButton("Open");
> $this -> pack_start($button_a,0);
> $button_b=new GtkButton("Run");
> $this -> pack_start($button_b,0);
> $button_c=new GtkButton("Close");
> $this -> pack_start($button_c,0);
> $close_c->connect("clicked", array($this,"OnClose")); // note 6
> ...... end cosntructor
> function OnClose ($widget )
> Here I would call the function OneFunction() in the parent class
> How can I make it ???
> View this message in context: http://www.nabble.com/Button-How-to-intercept-signal-from-a-istance-of-class-into-another-class-tp20223469p20223469.html > Sent from the Php - GTK - General mailing list archive at Nabble.com.