instone@bgsuvax.UUCP (Keith Instone) (07/18/90)
I can keep the user from sorting my stack with this simple little handler: on sort end sort but this doesn't work for the deleteCard message (that is, the empty handler doesn't keep the card from getting deleted). I tried adding the 'exit to Hypercard' command (among other things), but that didn't work either. Saving the card information and doing a 'new card' after the deletion won't work very well because I am using card id's a lot. All I REALLY want to do is ask "Are you sure you want to delete this card?" and abort if the user says NO. Any suggestions? Keith instone@andy.bgsu.edu Thanks in advance, HyperTalk-style: put "Advance" into adv put "Thanks" after char 3 of adv put adv
ehowe@dip.eecs.umich.edu (Ed Howe) (07/18/90)
In article <6057@bgsuvax.UUCP> instone@bgsuvax.UUCP (Keith Instone) writes: >I can keep the user from sorting my stack with this simple little >handler: > > on sort > end sort > >but this doesn't work for the deleteCard message (that is, the empty handler >doesn't keep the card from getting deleted). > <portion deleted> > >All I REALLY want to do is ask "Are you sure you want to delete this card?" >and abort if the user says NO. > >Any suggestions? Try putting this in your stack... on domenu what if what is "delete card" then answer "Are you sure?" with "Yes" or "No" if it is "Yes" then pass domenu else exit domenu end if pass domenu end domenu The routine can be easily modified to trap for other menu options as well. (Note that it is important to PASS DOMENU if WHAT isn't what you were trapping for...otherwise you'll totally disable menu commands...) ELH
moore@cs.washington.edu (Charles Moore) (07/18/90)
In article <6057@bgsuvax.UUCP>, instone@bgsuvax.UUCP (Keith Instone) writes: > I can keep the user from sorting my stack with this simple little > handler: > on sort > end sort > > but this doesn't work for the deleteCard message (that is, the empty handler > doesn't keep the card from getting deleted). > > All I REALLY want to do is ask "Are you sure you want to delete this card?" > and abort if the user says NO. The deleteCard message is NOT the message that causes HyperCard to delete the card. Rather, deleteCard gets sent to a card that is about to be deleted just prior to its deletion. This allows some handler to recognize that a deletion is about to occur and do something appropriate. The HyperCard Script Language Guide explains this and other purely informational system messages. What you want is: on doMenu theCommand if theCommand is "Delete Card" then answer "Are you sure you want to delete this card?" with "OK" and "Cancel" if it is "OK" then pass doMenu end if else pass doMenu end if end doMenu Note: The "else pass doMenu" part is VERY important. If you don't include it, you will suddenly discover that none of your menu commands work. Charles Moore
jk3t+@andrew.cmu.edu (Jonathan King) (07/18/90)
instone@bgsuvax.UUCP (Keith Instone) writes: > I can keep the user from sorting my stack with this simple little > handler: > > on sort > end sort This works because you have redefined the sort *command* to do nothing, and the command does not pass further up the hierarchy to hypercard, which would cheerfully shuffle your stack if it received it. > but this doesn't work for the deleteCard message (that is, the empty handler > doesn't keep the card from getting deleted). And that's because deleteCard is not a command, but a message that gets sent to a card just before it disappears. In effect, Hypercard has *already* pulled the trigger, but the victim gets the chance to have a few last requests... > I tried adding the 'exit to Hypercard' command (among other things), > but that didn't work either. Nope, this doesn't forestall the death sentence either. > Saving the card information and doing a 'new card' after the deletion > won't work very well because I am using card id's a lot. (Which is one reason I use card names a lot, but, hey, I use card names to hold up to 31 characters worth of neat card properties; too bad that user-definable properties of objects aren't yet a feature.) > All I REALLY want to do is ask "Are you sure you want to delete this card?" > and abort if the user says NO. But this you *can* do, even though the direct approach you tried doesn't work. The trick is to intercept the command to delete the card before it pulls the trigger. Note that you don't have to assume that the user would be deleting the card by using the menu item, since the only way to delete cards (in HC 1.2) is to to go through the "domenu" command. So if you had a button that deleted a card, you would just send 'domenu "Delete Card"' to the appropriate card. Then in that card's script you would put something like: on doMenu menuChoice if menuChoice is "Delete Card" then answer "Are you sure?" with "Delete" or "Cancel" if it is not "Delete" then exit doMenu end if pass do Menu --THIS IS A KEY LINE OR YOU'LL BE LOCKED OUT end doMenu That's it! This is essentially identical to the script on p. 86 of the apparently-soon-to-be-obsolete Hypercard Script Language Guide published by Addison Wesley. > Any suggestions? Hope this will work for you. > Keith instone@andy.bgsu.edu > Thanks in advance, HyperTalk-style: > put "Advance" into adv > put "Thanks" after char 3 of adv > put adv Or you could just replace adv with the omnipresnet it... jking [But seriously: is there going to be a new official Hypertalk Script Language Guide (HSLanG) for HC 2.0? If there is, will it appear pretty soon or next summer?]
bc@Apple.COM (bill coderre) (07/19/90)
Charles Moore: |Note: The "else pass doMenu" part is VERY important. If you don't include |it, you will suddenly discover that none of your menu commands work. Right. But let's correct the misperception started by Danny Goodman and tell everyone how to fix a broken menu handler. Danny believes that once you've got a broken doMenu handler, you're hosed, which is untrue. If you accidentally mess up your menu handler and can't do any menu commands (including, unfortunately, editing the script of the object containing the offensive handler), you can ALWAYS type send "edit the script of <the-containing-object>" to Hypercard provided that either the message box is visible OR you have blind typing enabled. This bypasses any intervening handlers. It is therefore a very good idea to make sure you have blind typing turned on at all times. If for some reason you can't type, or you feel you must reboot, simply wait a minute or so for any disk activity to finish, then reboot. Chances are, your stack will be okay. bill coderre hypercard smartypants
mhowitt@pro-angmar.UUCP (Matt Howitt) (07/22/90)
In-Reply-To: message from instone@bgsuvax.UUCP How 'bout this little trick: on deleteCard domenu "Copy Card" domenu "Paste Card" end deleteCard Not elegant, but the best way I know of. /s Matt Howitt | InterNet: pro-angmar!mhowitt@alphalpha.com Twisted-Pair Consulting | UUCP: uunet!alphalpha!pro-angmar!mhowitt ---------------------------| FidoNet: Matt Howitt on 1:101/121 Go Sox ..err... Red Sox! | USnail: 20 Cutter St. Belmont, MA 02178
jk3t+@andrew.cmu.edu (Jonathan King) (07/23/90)
mhowitt@pro-angmar.UUCP (Matt Howitt) writes: > In-Reply-To: message from instone@bgsuvax.UUCP > > How 'bout this little trick: > > on deleteCard > domenu "Copy Card" > domenu "Paste Card" > end deleteCard Pretty cute, actually, but I think the original poster was worried about preserving card id numbers, which this script doesn't do. Also, it could make a user pretty frustrated if he *wanted* to delete the card, but couldn't. So, if card ids are important or deleting the card makes sense, I would use the "Answer" approach posted earlier. > Matt Howitt | InterNet: pro-angmar!mhowitt@alphalpha.com > Twisted-Pair Consulting | UUCP: uunet!alphalpha!pro-angmar!mhowitt > ---------------------------| FidoNet: Matt Howitt on 1:101/121 > Go Sox ..err... Red Sox! | USnail: 20 Cutter St. Belmont, MA 02178 jking