Re: Problems with Gtk::Text and set_pointer and Text widget questions



Mikko Lipasti a écrit :

Hi everyone,

Am I just plain blind or is there something magic to this, but why don't
I see $text declared (my)? Forgetting that would produce the
'uninitialized value' error message. Perhaps you should s/widget/text/g;
(or vice versa) and try again?

mblanc erasme org wrote:

"Use of uninitialized value in subroutine entry at test2.pl line 143"
sub button_press {
        my ($widget, $event) = @_;
        my $len = $text->get_length()-1;
#       $text->set_point($len);
#       $text->set_point($text->get_point());
#       $text->set_point(3);
}

Mhhh, yes you're right. I am stupid. That code is not mine (it's from
the tutorial, for sample purposes, since my code is much bigger and
unreadable to write here :). 

But replacing text with widget doesn't help :

 sub button_press {
      my ($widget, $event) = @_;
      my $len = $widget->get_length()-1;
#1    $widget->set_point($len);
#2    $widget->set_point($widget->get_point());
#3    $widget->set_point(3);
}

All of them (1,2,3) report "Use of uninitialized value in subroutine
entry at test2.pl line 157" (the line of main Gtk;)

On the other hand, when I do :

sub button_press {
      my ($widget, $event) = @_;
      my $len = $widget->get_length()-1;
      $widget->set_point($len);
      print "done";
}

perl doesn't complain anymore ! But it doesn't "set the point" anyway
(may be I should signal_emit_stop_by_name for that ?).
Getting weirder !

Gtk expects a valid return value from an event handlers.
Try something like the following:

 sub button_press {
        my ($widget, $event) = @_;
        my $len = $widget->get_length()-1;
        $widget->set_point($len);
        1;
 }






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