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

  1. # NOTE: Derived from ..\blib\lib\Tk\Menubutton.pm.  Changes made here will be lost.
  2. package Tk::Menubutton;
  3.  
  4. #
  5. #-------------------------------------------------------------------------
  6. # Elements of tkPriv that are used in this file:
  7. #
  8. # cursor - Saves the -cursor option for the posted menubutton.
  9. # focus - Saves the focus during a menu selection operation.
  10. # Focus gets restored here when the menu is unposted.
  11. # inMenubutton - The name of the menubutton widget containing
  12. # the mouse, or an empty string if the mouse is
  13. # not over any menubutton.
  14. # popup - If a menu has been popped up via tk_popup, this
  15. # gives the name of the menu. Otherwise this
  16. # value is empty.
  17. # postedMb - Name of the menubutton whose menu is currently
  18. # posted, or an empty string if nothing is posted
  19. # A grab is set on this widget.
  20. # relief - Used to save the original relief of the current
  21. # menubutton.
  22. # window - When the mouse is over a menu, this holds the
  23. # name of the menu; it's cleared when the mouse
  24. # leaves the menu.
  25. #-------------------------------------------------------------------------
  26. #-------------------------------------------------------------------------
  27. # Overall note:
  28. # This file is tricky because there are four different ways that menus
  29. # can be used:
  30. #
  31. # 1. As a pulldown from a menubutton. This is the most common usage.
  32. # In this style, the variable tkPriv(postedMb) identifies the posted
  33. # menubutton.
  34. # 2. As a torn-off menu copied from some other menu. In this style
  35. # tkPriv(postedMb) is empty, and the top-level menu is no
  36. # override-redirect.
  37. # 3. As an option menu, triggered from an option menubutton. In thi
  38. # style tkPriv(postedMb) identifies the posted menubutton.
  39. # 4. As a popup menu. In this style tkPriv(postedMb) is empty and
  40. # the top-level menu is override-redirect.
  41. #
  42. # The various binding procedures use the state described above to
  43. # distinguish the various cases and take different actions in each
  44. # case.
  45. #-------------------------------------------------------------------------
  46. # Menu::Bind --
  47. # This procedure is invoked the first time the mouse enters a menubutton
  48. # widget or a menubutton widget receives the input focus. It creates
  49. # all of the class bindings for both menubuttons and menus.
  50. #
  51. # Arguments:
  52. # w - The widget that was just entered or just received
  53. # the input focus.
  54. # event - Indicates which event caused the procedure to be invoked
  55. # (Enter or FocusIn). It is used so that we can carry out
  56. # the functions of that event in addition to setting up
  57. # bindings.
  58. sub ClassInit
  59. {
  60.  my ($class,$mw) = @_;
  61.  $mw->bind($class,"<Enter>",'Enter');
  62.  $mw->bind($class,"<Leave>",'Leave');
  63.  $mw->bind($class,"<1>",'ButtonDown');
  64.  $mw->bind($class,"<Motion>",['Motion',"up",Ev(X),Ev(Y)]);
  65.  $mw->bind($class,"<B1-Motion>",['Motion',"down",Ev(X),Ev(Y)]);
  66.  $mw->bind($class,"<ButtonRelease-1>",'ButtonUp');
  67.  $mw->bind($class,"<space>",'PostFirst');
  68.  $mw->bind($class,"<Return>",'PostFirst');
  69.  return $class;
  70. }
  71.  
  72. 1;
  73.