Overwrite mode in Gtk2::TextView

Hello all,
I have a small but baffling problem, hopefully with an obvious solution.
I'm trying to write text to a Gtk2::TextView with overwrite mode turned on. For example, I might want to write the text:
> Hello world
...then overwrite the first word, to produce:
> Howdy world
...but I am actually getting:
>HowdyHello world
...indicating that overwrite mode isn't working at all. Any ideas, oh great Gtk megabrain?
use strict;
use diagnostics;
use warnings;
use Glib qw(TRUE FALSE);
use Gtk2 '-init';
# Open a Gtk2 window containing a Gtk2::TextView
my $window = Gtk2::Window->new('toplevel');
$window->set_title('Overwrite test');
$window->set_default_size(400, 400);
$window->signal_connect('delete-event' => sub {
my $scrollWin = Gtk2::ScrolledWindow->new(undef, undef);
$scrollWin->set_policy('automatic', 'automatic');      
my $textView = Gtk2::TextView->new;
# Display some text
my $buffer = $textView->get_buffer();
$buffer->insert($buffer->get_start_iter(), "Hello world");
# Turn on overwrite mode

# Check it's really on
print "Overwrite mode: " . $textView->get_overwrite . "\n";
# Overwrite the first word, changing "Hello world" to "Howdy world"
$buffer->insert($buffer->get_start_iter(), "Howdy");
# All done

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