Path: utzoo!utgpu!news-server.csri.toronto.edu!rutgers!psuvax1!julius.cs.uiuc.edu!zaphod.mps.ohio-state.edu!van-bc!rsoft!mindlink!a347 From: John_Miller@mindlink.UUCP (John Miller) Newsgroups: comp.sys.mac.hypercard Subject: Re: Question about protocol for trapping menu items. Message-ID: <4621@mindlink.UUCP> Date: 29 Jan 91 14:42:26 GMT Organization: MIND LINK! - British Columbia, Canada Lines: 63 > Ok, but what if you're the top stack in the stacksInUse and > there's another stack below you that also has a doMenu > handler that closes its windows? If you send the command > straight to HyperCard the other stacks never get it. I've > been wrestling with this general problem (passing on a message > so other stacks get it but still doing something after the > message is "finished") and I haven't come up with a good solution. > I've resorted to setting a global flag and checking it in an idle > handler, but I don't really like doing it that way. Would it be > better to find my stack's place in the stacksInUse list and send > the message on to the following stack? Any suggestions? A solution is to use a global variable, but it doesn't have to be within the idle handler. It can all be handled within the doMenu menu handler. The trick is to deliberately cause one level of recursion. This code relies on the fact that a global variable that is declared but not initialized is considered to be empty: a very useful feature of HyperTalk. on doMenu theItem -- This global is only declared in this handler: nowhere else global amRecursing if amRecursing is not empty then play flute -- Remove from production code :) pass doMenu else if theItem is "Compact Stack" then close window "MyPalette" put true into amRecursing -- Any non-empty value would do send "doMenu Compact Stack" to me -- causes recursion play boing -- Remove from production code :) put empty into amRecursing palette "MyPalette", "345,80" else pass doMenu end if end doMenu Actually, is the warning about hiding palettes valid? HyperCard doesn't complain when I try to compact a stack with a custom palette. It does complain when I try to compact a stack X that contains a windoid that is controlled by an XCMD located in stack X. Presumably, the Palette XCMD "lets go" of the PLTE and PICT resources once it has created the window. (Yes? No?) An unrelated palette question: is the format of the PLTE resource documented or do I have to reverse-engineer it. I was thinking of creating some XCMDs that would allow customization: "If you don't like the default look of the windoid, create your own palette using the Palette Maker. Your palette should have four buttons: the first will invoke ... the second will invoke ...." ---------------------------------------------------------------------- John Miller (604) 433-1795 Symplex Systems AppleLink (rarely) CDA0461 Burnaby, British Columbia Fax: (604) 430-8516 Canada usenet: john_miller@mindlink.uucp ----------------------------------------------------------------------