Subject: | scrolled text widget hangs |
Date: | Fri, 6 May 2016 06:33:41 +0000 (UTC) |
To: | "bug-Tk [...] rt.cpan.org" <bug-Tk [...] rt.cpan.org> |
From: | David Walsh <alohadw1 [...] yahoo.com> |
I've noticed what appears to be a bug in the perl Tk scrolled text widget that causes it to hang when large amounts of text are selected by dragging with the mouse. The problem seems to be due to the interaction between the mouse selection event and the horizontal scrollbar, which appears and disappears during text selection, depending on the length of the text lines being selected. I wrote the short script below to illustrate the problem in the simplest way I could - documentation inside the script may help illustrate the issue better. I'm running ubuntu 14.04.4, perl 5.18.2, and perl-Tk-804.033. Thanks for looking into this. Regards, David Walsh
#!/usr/bin/perl
#
# script to illustrate dysfunctional interaction between horizontal scrollbar
# in scrolled text widget when selecting large amounts of text by dragging with
# mouse B1. The problem is not entirely predictable, but seems to happen when
# the horizontal scrollbar appears and disappears several times while large amounts
# of text are being selected by dragging the mouse. Occurrence depends on horizontal
# dimension of the widget relative to line length, and does not seem to occur if the
# widget is either "too narrow" or "too wide". It seems to occur most often when the
# width of the widget is slightly less than the max line length, so that the horizontal
# scroll bar appears and disappears many times while large amounts of text are being
# selected. The only work-around I have come up with for this is to make the horizontal
# scrollbar "non-automatic" (i.e. so it's always there), or to eliminate it entirely.
# Once the problem occurs the only solution is to re-start the widget.
use Tk;
require Tk::ROText;
$mw = MainWindow->new(-title=>"TEST");
$mw->geometry("1100x600");
$mw->resizable(0,0);
$NLINES = 2500;
$frame = $mw->Labelframe(-font=>['Courier','14','normal'],-borderwidth=>2) -> pack(-fill=>"both", -side=>"top", -expand=>"true");
# the following line creates 'automatic' scrollbars at the bottom of the widget and
# at the right, which appear automatically when text width/height exceeds widget
# dimension
$mssg_text = $frame->Scrolled('ROText',-font=>['Courier','14'],-background=>"wheat",-scrollbars=>"osoe",-foreground=>"black",-wrap=>"none") -> pack(-fill=>"both", -side=>"top", -expand=>"true");
# in the following line the horizontal scrollbar has been disabled
#$mssg_text = $frame->Scrolled('ROText',-font=>['Courier','14'],-background=>"wheat",-scrollbars=>"oe",-foreground=>"black",-wrap=>"none") -> pack(-fill=>"both", -side=>"top", -expand=>"true");
&FillTextWidget();
MainLoop;
#----------------------------------------
sub FillTextWidget {
# fill text widget with random-length lines
for ($knt1=1;$knt1<$NLINES;$knt1++) {
$line = $knt1 . " TEST";
$randomNumber = int(rand(20));
for ($knt2=0;$knt2<$randomNumber;$knt2++) {
$line = $line . " TEST";
}
$line = $line . "\n";
$mssg_text->insert('end',"$line");
}
}