davidj has asked for the wisdom of the Perl Monks concerning the following question:

This is my first post, so please bear with me. Here's my problem: I am loading a file into a Tk textbox. There are more lines in the file than there are in the textbox. Therefore, some lines are not shown. After loading the file, I search for patterns in the text and programatically highlight the matches. Here is what I want to happen: When text is highlighted, I would like the textbox to automatically scroll down so that the hightlighted text is visible if it is not already so. I have spent some time searching the internet for a solution but I have come up empty. Much thanks in advance, davidj

Replies are listed 'Best First'.
Re: using scrollbars in Perl/Tk
by matija (Priest) on May 08, 2004 at 21:16 UTC
    You need to create a scrolled textbox, using Tk::Scrolled. Mark what you need, and then manipulate the scrollbars (through their methods) to display the highlighed text.

    (You might also check out Tk::Textbox's own search method which does some of the things that you intend to do).

      Shortly after my post I figured out what I needed to do. The textbox does use the Scrolled method so that wasn't the problem. the Text command I had forgotten was $widget->see('position'). After implementing that it works just like it need it to.