Subject: | [macOS] "FindNext" with direction "-forwards" in a Text widget does not work |
Date: | Sat, 9 Jun 2018 11:24:23 +0200 |
To: | bug-Tcl-pTk [...] rt.cpan.org |
From: | "Kelly O'brein" <kellyobrein77 [...] gmail.com> |
OS: macOS HighSierra
Module: Tcl-pTk-0.92
Perl: 5.24
Tk: 8.5 (version delivered with macOS)
The "FindNext" with direction "-forwards" in a Text widget does not work
(while direction "-backwards" is working fine). Note that the same with
Perl/Tk is working fine as the following example demonstrates:
use strict;
use warnings;
#use Tk;
use Tcl::pTk;
my %w;
$w{mw} = MainWindow->new;
$w{topfr} = $w{mw}->Frame()->pack( -expand => 1, -fill => 'x' );
$w{textfr} = $w{mw}->Frame()->pack( -expand => 1, -fill => 'both' );
$w{topfr}->Button(
-text => 'Previous',
-command => sub { nextText('-backwards') }
)->pack( -side => 'left' );
$w{searchstring} =
$w{topfr}->Entry( -text => 'text', )->pack( -side => 'left' );
$w{topfr}->Button(
-text => 'Next',
-command => sub { nextText('-forwards') }
)->pack( -side => 'left' );
$w{textWindow} =
$w{textfr}->Scrolled( 'Text', -scrollbars => 'ose' )
->pack( -expand => 1, -fill => 'both' );
$w{textWindow}->insert(
'end',
q|I have a Scrolled Text widget in my application. I am trying to
implement an incremental search of a string on this text widget.
I have come up with the following logic , but it only highlights
the first occurence and not the remaining ocuurences. Please help
me to make it incremental for the entire text widget.
Following is my code |
);
$w{textWindow}->focus;
MainLoop;
sub nextText {
my $direction = shift;
my $string = $w{searchstring}->get;
$w{textWindow}->FindNext( $direction, '-exact', '-nocase', $string );
}