home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #26 / NN_1992_26.iso / spool / comp / sys / amiga / programm / 15750 < prev    next >
Encoding:
Internet Message Format  |  1992-11-12  |  2.3 KB

  1. Path: sparky!uunet!walter!att-out!rutgers!cbmvax!peter
  2. From: peter@cbmvax.commodore.com (Peter Cherna)
  3. Newsgroups: comp.sys.amiga.programmer
  4. Subject: Re: Hooks?  Simple explaination please!
  5. Keywords: Hooks Explaination
  6. Message-ID: <37007@cbmvax.commodore.com>
  7. Date: 12 Nov 92 17:23:17 GMT
  8. References: <BxI9n0.HDK@ccu.umanitoba.ca>
  9. Reply-To: peter@cbmvax.commodore.com (Peter Cherna)
  10. Organization: Commodore-Amiga, Inc.  West Chester, PA.
  11. Lines: 40
  12.  
  13. In article <BxI9n0.HDK@ccu.umanitoba.ca> umoster0@ccu.umanitoba.ca (Sean K. Ostermann) writes:
  14. >I need a simple (but not too simple) explaination about Hooks.  What are
  15. >they used for, why are they in the OS and how can one use them?
  16.  
  17. A hook is basically a standard way for the OS to "call-back" into your
  18. program.  Ordinarily, your application calls the OS, but Release 2 adds
  19. a bunch of features that are helped out when the OS can invoke application
  20. code.
  21.  
  22. For example, you can create a custom gadget type (for instance, a dial
  23. gadget), supplying the code to handle all that Intuition needs you to
  24. handle (eg. handling queries of the kind "does this mouse coordinate hit you?",
  25. "please go active", "please handle this mouse-input event", "please go
  26. inactive", etc.  You supply a hook, which in turn contains a pointer
  27. to your routine, when you install your class.
  28.  
  29. The hook has a node plus three fields.  The h_Entry field is the one
  30. that is actually called by the OS.  If you're an assembler program,
  31. that's probably all you need.  If you're programming in C, then this
  32. entry needs to set up your base register and possibly convert the
  33. register arguments to stack-based ones.  By convention, the h_SubEntry
  34. is used to store a pointer to the C-language routine to call, and h_Data
  35. is used to hold for the base register value.
  36.  
  37. Aside from boopsi objects, other examples of things that use hooks
  38. include the custom string editing hook and the layers backfill hook.
  39. The former allows control over how keystrokes are interpreted in
  40. string gadgets, and the latter allows you to backfill a particular
  41. window with a pattern in a very efficient manner.
  42.  
  43. >Thanks,
  44. >
  45. >Sean
  46.  
  47.      Peter
  48. --
  49. Peter Cherna, User Interface Development Group, Commodore-Amiga, Inc.
  50. {uunet|rutgers}!cbmvax!peter    peter@cbmvax.commodore.com
  51. My opinions do not necessarily represent the opinions of my employer.
  52. "I believe it's bad luck to be superstitious."
  53.