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

  1. # NOTE: Derived from blib\lib\Tk.pm.  Changes made here will be lost.
  2. package Tk;
  3.  
  4. sub focusNext
  5. {
  6.  my $w = shift;
  7.  my $cur = $w;
  8.  while (1)
  9.   {
  10.    # Descend to just before the first child of the current widget.
  11.    my $parent = $cur;
  12.    my @children = $cur->FocusChildren();
  13.    my $i = -1;
  14.    # Look for the next sibling that isn't a top-level.
  15.    while (1)
  16.     {
  17.      $i += 1;
  18.      if ($i < @children)
  19.       {
  20.        $cur = $children[$i];
  21.        next if ($cur->toplevel == $cur);
  22.        last
  23.       }
  24.      # No more siblings, so go to the current widget's parent.
  25.      # If it's a top-level, break out of the loop, otherwise
  26.      # look for its next sibling.
  27.      $cur = $parent;
  28.      last if ($cur->toplevel() == $cur);
  29.      $parent = $parent->parent();
  30.      @children = $parent->FocusChildren();
  31.      $i = lsearch(\@children,$cur);
  32.     }
  33.    if ($cur == $w || $cur->FocusOK)
  34.     {
  35.      $cur->Tk::focus;
  36.      return;
  37.     }
  38.   }
  39. }
  40.  
  41. 1;
  42.