Gtk2::Entry question



Hi!
 
 I need to make an autocomplete task on several entry widgets and I have a small  problem. 
 
 Given the following code: 
 
        my %h = (i => 'III', b => 'BBB',  c => 'CCC');
        $entry->signal_connect(
            changed => sub {
                    my $e = shift;
                    my $text = $e->get_text;
 
                    if ($text) {
                        $text =~ s/\b([ibc])\s/$h{$1}/i and do {
                          $e->set_text($text);
 
                          $e->set_position($e->get_position+length($h{$1}));
                          #^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
                    }
            });
 
 The promblem is the cursor position is not where I want it to be, ie at the end of the text in the entry for 
example.
 
 Tnx.
 -- 



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