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

  1. # NOTE: Derived from ..\blib\lib\Tk\Menu.pm.  Changes made here will be lost.
  2. package Tk::Menu;
  3.  
  4. # NextEntry --
  5. # Activate the next higher or lower entry in the posted menu,
  6. # wrapping around at the ends. Disabled entries are skipped.
  7. #
  8. # Arguments:
  9. # menu - Menu window that received the keystroke.
  10. # count - 1 means go to the next lower entry,
  11. # -1 means go to the next higher entry.
  12. sub NextEntry
  13. {
  14.  my $menu = shift;
  15.  my $count = shift;
  16.  if ($menu->index("last") eq "none")
  17.   {
  18.    return;
  19.   }
  20.  $length = $menu->index("last")+1;
  21.  $active = $menu->index("active");
  22.  if ($active eq "none")
  23.   {
  24.    $i = 0
  25.   }
  26.  else
  27.   {
  28.    $i = $active+$count
  29.   }
  30.  while (1)
  31.   {
  32.    while ($i < 0)
  33.     {
  34.      $i += $length
  35.     }
  36.    while ($i >= $length)
  37.     {
  38.      $i += -$length
  39.     }
  40.    $state = eval {local $SIG{__DIE__};  $menu->entrycget($i,"-state") };
  41.    last if (defined($state) && $state ne "disabled");
  42.    return if ($i == $active);
  43.    $i += $count
  44.   }
  45.  $menu->activate($i);
  46.  $menu->postcascade($i)
  47. }
  48.  
  49. 1;
  50.