Re: Signal handler args


I not too happy about the syntax myself,
but the behavior is consistent with how it is done in C
and probably in old gtk-perl(?)

The reason probably is that these signalhandlers are
most often different kind of beast.
You should be able to test the second arggument with
something like (untested code follows):

if (defined $arg2 and $arg2->isa("Gtk2::Gdk::Event")) 

I am willing to change this in line with your
suggestion if we can reach consensus.


On Tue, Oct 22, 2002 at 04:11:32AM +0100, Dermot Musgrove wrote:
Hi all,

Following a previous thread, I tried to connect a signal handler to
'button_press_event' and was delighted that it worked - however ...

In the event handler, 'print Dumper(\ _)' produces:
(I passed {'data'=>'test data'} to the data arg of signal_connect)
$VAR1 = [
          bless( do{\(my $o = 137040016)}, 'Gtk2::Button' ),
          bless( do{\(my $o = 137239944)}, 'Gtk2::Gdk::Event' ),
            'data' => 'test data'

Please can we have the args to the signal handlers delivered as:

  my ($widgetref, $dataref) = @_;

or for an event handler

  my ($widgetref, $dataref, $eventref) = @_;

At least this way, it is possible to write generic handlers that do
not need to know whether the handler is connected to a signal or an
event in order to work. It also makes it possible to auto-generate
simple signal handlers for programmers to edit (Glade-Perl-Two will 
do this so I have an interest :-)

I don't know if it is simple to translate the Gtk2::Gdk::Event into
an anonymous hash and pass that to the handler as Gtk-Perl does but 
IMO that is any easier thing to use and understand.

Regards, Dermot

gtk-perl-list mailing list
gtk-perl-list gnome org

Göran Thyni
 Senior Technical Consultant
 Luleå, Sweden

[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]