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

  1. # NOTE: Derived from ..\blib\lib\Tk\Menu.pm.  Changes made here will be lost.
  2. package Tk::Menu;
  3.  
  4. # ButtonDown --
  5. # Handles button presses in menus. There are a couple of tricky things
  6. # here:
  7. # 1. Change the posted cascade entry (if any) to match the mouse position.
  8. # 2. If there is a posted menubutton, must grab to the menubutton so
  9. #    that it can track mouse motions over other menubuttons and change
  10. #    the posted menu.
  11. # 3. If there's no posted menubutton (e.g. because we're a torn-off menu
  12. #    or one of its descendants) must grab to the top-level menu so that
  13. #    we can track mouse motions across the entire menu hierarchy.
  14.  
  15. #
  16. # Arguments:
  17. # menu - The menu window.
  18. sub ButtonDown
  19. {
  20.  my $menu = shift;
  21.  $menu->postcascade("active");
  22.  if (defined $Tk::postedMb)
  23.   {
  24.    $Tk::postedMb->grabGlobal
  25.   }
  26.  else
  27.   {
  28.    while ($menu->overrideredirect
  29.           && $menu->parent->IsMenu
  30.           && $menu->parent->ismapped 
  31.          )
  32.     {
  33.      $menu = $menu->parent;
  34.     }
  35.    $menu->grabGlobal;
  36.   }
  37. }
  38.  
  39. 1;
  40.