Re: Another silly newbie question



Fred. Oger said:
Hello everyone,

Could someone tell me how I could pass several args to my callback
function ?

$okbutton->signal_connect('clicked',\&ValidateLogin,$fieldUid,$fieldPwd);

you can pass them as an array reference (or hash reference etc)

$okbutton->signal_connect( clicked => \&ValidateLogin,
                           [ $fieldUid, $fieldPwd ]);

sub ValidateLogin
{
    my $btn = shift;
    my $udata = shift;
# $udata->[0] is $filedUid
# $udata->[1] is $filedPwd
}

my $udata = shift could be changed to my @udata = @{shift} and then $udata[0],
$udata[1] etc. much the same technique can be used for a hash reference.

It works perfectly with gtk1.2 but it's not accepted in Gtk2 ?

that was a design decision (for various reasons i don't remember all of now)
and since the solution is really simple (as above) it was deiced to following
the c bindings.

-rm



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