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?
 
---
 
#!/usr/bin/perl
 
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_position('center');
$window->set_default_size(400, 400);
$window->signal_connect('delete-event' => sub {
 
    Gtk2->main_quit();
    exit;
});
             
my $scrollWin = Gtk2::ScrolledWindow->new(undef, undef);
$window->add($scrollWin);
$scrollWin->set_policy('automatic', 'automatic');      
$scrollWin->set_border_width(0);
 
my $textView = Gtk2::TextView->new;
$scrollWin->add_with_viewport($textView);
$textView->set_wrap_mode('word-char');
$textView->set_justification('left');
 
# Display some text
my $buffer = $textView->get_buffer();
$buffer->insert($buffer->get_start_iter(), "Hello world");
$window->show_all();
 
# Turn on overwrite mode
$textView->set_overwrite(TRUE);

# 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
Gtk2->main();
  


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