Re: object connect to class own function
| From: | Rich Payne | Date: | Mon, 04 Mar 2002 17:05:00 +0000 |
| Subject: | Re: object connect to class own function | ||
| References: | 1 | Groups: | php.gtk.general |
| Request: | Send a blank email to php-gtk-general+get-1420@lists.php.net to get a copy of this message | ||
This is becuase of PHP's (rather strange way I think) of calling methods
in the same object. You need to use a syntax like this:
$this->db_use_button->connect('clicked', array($this,'db_use()'));
$this->db_refresh_button->connect('clicked',array($this,'db_refresh'));
If you need to pass parameters to the function you'd do it like this:
$this->db_use_button->connect('clicked',
array($this,'db_use()'),$param1,$param2);
etc...etc...
hope that helps,
--rdp
On Mon, 4 Mar 2002, Adrian Immler wrote:
> hi !
>
> i have a class that constructs a window with some buttons, a clist and so on
> ...
>
> in this class i have also 2 buttons that should be connected to functions in
> the same class ...
>
> example:
>
> class test {
> #<snip>
> var $db_use_button;
> var $db_refresh_button;
> #<snip>
>
> function test(){ #constructor
> #<snip>
> $this->db_use_button = &new GtkButton('Use Database');
> $this->db_refresh_button = &new GtkButton('Refresh List');
>
> $this->db_use_button ->connect('clicked', 'db_use()');
> $this->db_refresh_button ->connect('clicked',
> '$this->db_refresh');
> #<snip>
> }
>
> function db_refresh ($emitter){
> #<snip>
> }
>
>
> }
>
>
>
> the class also contains a function called db_use() but either the db_use()
> nor the db_refresh() function is called when the button is clicked. instead
> i get the error message:
>
> Warning: Unable to call signal callback '$this->db_refresh' specified in
> <file> on <line>
>
>
> what am i doing wrong ? how has the ->connect have to look like ?
>
>
>
>
--
Rich Payne
http://talisman.mv.com