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

  1. # NOTE: Derived from ..\blib\lib\Tk\Scrollbar.pm.  Changes made here will be lost.
  2. package Tk::Scrollbar;
  3.  
  4. # tkScrollDrag --
  5. # This procedure is called for each mouse motion even when the slider
  6. # is being dragged.  It notifies the associated widget if we're not
  7. # jump scrolling, and it just updates the scrollbar if we are jump
  8. # scrolling.
  9. #
  10. # Arguments:
  11. # w -        The scrollbar widget.
  12. # x, y -    The current mouse position.
  13.  
  14. sub Drag 
  15. {my $w = shift;
  16.  my $e = $w->XEvent;
  17.  return unless (defined $initMouse);
  18.  my $f = $w->fraction($e->x,$e->y);
  19.  my $delta = $f - $initMouse;
  20.  if ($w->cget("-jump"))
  21.   {
  22.    if (@initValues == 2)
  23.     {
  24.      $w->set($initValues[0]+$delta,$initValues[1]+$delta);
  25.     }
  26.    else
  27.     {
  28.      $delta = int($delta * $initValues[0]);
  29.      $initValues[2] += $delta;
  30.      $initValues[3] += $delta;
  31.      $w->set(@initValues);
  32.     }
  33.   }
  34.  else
  35.   {
  36.    $w->ScrlToPos($initPos+$delta);
  37.   }
  38. }
  39.  
  40. 1;
  41.