Bug report for signal "insert-text"



Hi,

this is my first posting to the list so I would like to thank you for
doing such a great thing! I tried the perl bindings for other GUI
libraries and I have to say your perl integration is really wonderful! :-)

I am using the Debian packet libgtk2-perl 1.00-1 from http://www.raspberryheaven.net/~hannibal/debs/unstable/. I tried to make an entry button to accept only numeric values. I did it with the following code.

As I read the doc, the fourth parameter to the callback function should
be the insert position inside the text. But instead it is a very high number. I believe it is a pointer to the real value. I used $wid->get_position instead as a work-around. But worse: In http://developer.gnome.org/doc/API/2.0/gtk/GtkEditable.html#GtkEditable-insert-text I read that this is an in-out-parameter. So it is not possible to change this value (to modify the text in an own callback) because of this bug.

------------------------------------------------------------------------
   $self->{entry}->signal_connect('insert-text'=>sub{
     my($entry,$new,$len,$pos)= _;
     my $text=$entry->get_text;
     substr($text,$entry->get_position,0)=$new;
     if($text !~ /^-?(\d)*$/){
       $entry->signal_stop_emission_by_name('insert-text');
       Gtk2::Gdk::beep($entry);
     }
   });
------------------------------------------------------------------------

Thanks,

Thomas




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