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