Re: gtk signal_connect error

On Thu, 2006-05-04 at 16:24 +0200, wout clymans wrote:
i am trying to write a little perl/Gtk app by hand and now i am stuck on 
this (probably) stupid mistake

when i click on one of the buttons on the dialog, a sub has to be called 
with extra arguments (textfields, checkbutton) but i can't get the 
arguments to work in the sub!

$dialog->signal_connect('response' , sub {
        my ($dialog, $response, @data) = @_;

        if($response eq 'ok'){
            $uid = $data[0]->get_text;
            $passwd = $data[1]->get_text;
            print $uid; #just for testing
            print $passwd; #just for testing
            if ($data[3]->get_active) {
            else {
    },[$txtLogin, $txtPassword, $checkRemember] );

when i press the ok button, i get this error:

*** unhandled exception in callback:
***   Can't call method "get_text" on unblessed reference

this means that $data[0] is unblessed, but how can i solve it?

I think that @data is not what you think it.

You're passing in a arrayref to the signal connect, but in the function
you're treating it as a regular array.  Change @data to $data, and
$data[0] to $data->[0], etc.


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