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}) - 2)};
                          #^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
                    }
            });

The promblem is that the cursor position is not where I wand 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]