home *** CD-ROM | disk | FTP | other *** search
/ CD Actual Thematic 7: Programming / CDAT7.iso / Share / Editores / Perl5 / perl / lib / site / auto / Tk / Entry / SeeInsert.al < prev    next >
Encoding:
Text File  |  1997-08-10  |  846 b   |  36 lines

  1. # NOTE: Derived from ..\blib\lib\Tk\Entry.pm.  Changes made here will be lost.
  2. package Tk::Entry;
  3.  
  4. # SeeInsert
  5. # Make sure that the insertion cursor is visible in the entry window.
  6. # If not, adjust the view so that it is.
  7. #
  8. # Arguments:
  9. # w - The entry window.
  10. sub SeeInsert
  11. {
  12.  my $w = shift;
  13.  my $c = $w->index("insert");
  14. #
  15. # Probably a bug in your version of tcl/tk (I've not this problem
  16. # when I test Entry in the widget demo for tcl/tk)
  17. # index("\@0") give always 0. Consequence :
  18. #    if you make <Control-E> or <Control-F> view is adapted
  19. #    but with <Control-A> or <Control-B> view is not adapted
  20. #
  21.  my $left = $w->index("\@0");
  22.  if ($left > $c)
  23.   {
  24.    $w->xview($c);
  25.    return;
  26.   }
  27.  my $x = $w->width;
  28.  while ($w->index("@" . $x) <= $c && $left < $c)
  29.   {
  30.    $left += 1;
  31.    $w->xview($left)
  32.   }
  33. }
  34.  
  35. 1;
  36.