Skip Menu |

This queue is for tickets about the Tcl-pTk CPAN distribution.

Report information
The Basics
Id: 125532
Status: resolved
Priority: 0/
Queue: Tcl-pTk

People
Owner: CAC [...] cpan.org
Requestors: kellyobrein77 [...] gmail.com
Cc: CAC [...] cpan.org
AdminCc:

Bug Information
Severity: (no value)
Broken in: (no value)
Fixed in: 0.93



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 ); }
On Sat Jun 09 04:24:33 2018, kellyobrein77@gmail.com wrote:
> 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 []

Thanks for reporting this.

If I'm understanding the history of things correctly, some time ago Perl/Tk changed which strings were accepted (and documented as acceptable) for the direction. It used to be -forward and -reverse, but it got changed to -forwards and -backwards for consistency, while apparently still tolerating some other strings. See https://rt.cpan.org/Ticket/Display.html?id=51552

I guess that since then a few examples (such as the test program you've found) have appeared which use the newer suggested direction strings. But Tcl::pTk never incorporated the improvement from Perl/Tk, so it still expects exactly -forward (no 's').

Simply put, if you change the direction to -forward, it will work with both Perl/Tk and the current Tcl::pTk. But the ideal solution will still be to incorporate the Perl/Tk improvement into Tcl::pTk so it is closer to remaining compatible with Perl/Tk.

(I hope there's a better way of incorporating Perl/Tk improvements other than manually copying their changes over as folks gradually keep finding what's broken…)
I've released Tcl::pTk 0.93, which includes the relevant changes in Perl/Tk to support the newer direction syntax: '-forwards' (or an abbreviated substring like '-forward' or '-f') will use a forward search direction, otherwise the direction is reverse (so both '-reverse' and '-backwards' would work).

Please reopen this if you find there's still an issue.

PS: I recently added a p5-tcl-ptk port for MacPorts, in case you'd like to try that. However the existing ports for Tk extensions (e.g. Tix and Tktable) only support X11 currently, so there is some functionality not yet available to p5-tcl-ptk when used from macOS aqua.