Re: SIgnal connect to a object method?
- From: Grant McLean <grant mclean net nz>
- To: "John M. Burian" <john burian org>
- Cc: gtk-perl-list gnome org
- Subject: Re: SIgnal connect to a object method?
- Date: Thu, 07 Dec 2006 10:31:33 +1300
On Wed, 2006-12-06 at 16:09 -0500, John M. Burian wrote:
This is probably more of a syntax question than a gtk-perl question, but:
Can I have signal_connect call an object method? Say I've got a class
that contains an object method 'bar'; 'foo' is an object of this class,
and I've got a combobox 'cbox'. I want to
$cbox->signal_connect (changed => $foo->bar);
What you want is a 'closure':
$cbox->signal_connect (changed => sub { $foo->bar(@_) } );
This creates an anonymous subroutine that retains visibility to lexical
variables from the scope in which it was declared.
Regards
Grant
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]