Path: utzoo!utgpu!news-server.csri.toronto.edu!cs.utexas.edu!wuarchive!uunet!snorkelwacker.mit.edu!bloom-beacon!vaxeline!bootsie!olson From: olson@bootsie.uucp (Eric K. Olson) Newsgroups: comp.sys.mac.programmer Subject: Re: clikLoop -- Unclear on the concept Message-ID: <1991Feb21.043729.25610@bootsie.uucp> Date: 21 Feb 91 04:37:29 GMT References: <2305.27c2a58c@spacm1.spac.spc.com> Organization: Lexington Software Design, Lexington, MA Lines: 57 In article <2305.27c2a58c@spacm1.spac.spc.com> audit038@spacm1.spac.spc.com writes: >In using my own clikLoop function with TE records I came up with the following >problem: > >Window A has a TE record with a ptr to clikLoop A. (works fine) >Create Window B with another TE record and clikLoop B. > >Now when I return to window A, clikLoop A is no longer called. > >If I put a SetClikLoop in my window update routine (i.e every time the >window becomes active I reset the clikLoop ptr) the clikLoop routine is once >again called. This is a misfeature of the glue provided by Apple for SetClikLoop(). This misfeature occurs in THINK C and MPW C (because they both use Apple glue). To avoid the problem, don't use SetClikLoop(). Instead, use this: Instead of SetClikLoop(realClickLoop): (*teHandle)->clikLoop = (ProcPtr) TEClikGlue; Here's the glue: Boolean TEClickGlue() { asm { move.l d2,-(a7) ; Preserve d2 clr.b -(a7) ; Boolean return jsr realClickLoop ; Jump to the routine move.b (a7)+,d0 ; Result in d0 move.l (a7)+,d2 ; Restore d2 tst.b d0 ; Set cond codes rts } } A Sample clikLoop function: pascal Boolean realClickLoop() { SysBeep(1); return TRUE; } Note that if you do it this way, you still need a separate glue procedure for each possible clikLoop function. There's probably a better way, but this works, anyway. -Eric -- Eric K. Olson, Editor, Prepare() NOTE: olson@bootsie.uucp doesn't work Lexington Software Design Internet: olson@endor.harvard.edu 72A Lowell St., Lexington, MA 02173 Uucp: harvard!endor!olson (617) 863-9624 Bitnet: OLSON@HARVARD