Path: utzoo!attcan!utgpu!news-server.csri.toronto.edu!cs.utexas.edu!usc!apple!jdevoto From: jdevoto@Apple.COM (Jeanne A. E. DeVoto) Newsgroups: comp.sys.mac.hypercard Subject: Re: FAQ: miniature card picture? Message-ID: <47577@apple.Apple.COM> Date: 24 Dec 90 03:33:32 GMT References: <1990Dec19.003310.12043@portia.Stanford.EDU> <47512@apple.Apple.COM> <1990Dec21.080810.27139@portia.Stanford.EDU> Organization: Apple Computer Inc., Cupertino, CA Lines: 71 In article <1990Dec21.080810.27139@portia.Stanford.EDU> ralphm@portia.Stanford.EDU (Ralph Melton) writes further concerning miniature card pictures: >I am indeed doing this in a script. It seems to me very unfriendly to >heedlessly overwrite the clipboard. Is there any way I can either a) >generate the miniature picture without clobbering the clipboard, or b) >save the contents of the clipboard, no matter what the nature of those >contents, and restore them after my finagling? Not easily, not without an XCMD (and I have not seen an XCMD that will do this, although it seems as though it would be possible to write a SaveScrap/RestoreScrap pair). You can check which of HyperCard's scrap types is on the clipboard, if any, by checking the wording of the "Paste" menu item: if menu "Edit" contains "Paste Text" then -- paste the text into a field else if menu "Edit" contains "Paste Picture" then -- paste the graphic onto a convenient card set aside for the purpose else if menu "Edit" contains "Paste Card" then -- paste the card where you can grab it later end if doMenu "Copy card" go card "Map" type "v" with shiftKey,commandKey -- now restore whatever you moved off the clipboard As you can see, this is a pretty ugly solution; it requires setting aside a card with an empty picture and an empty field to accept pictures or text. It has several failure modes: for instance, the clipboard might contain more than 29000 characters of text, in which case you'll get an error when you try to paste it in to a field; the graphic on the clipboard might be too large for the card you try to paste it into, resulting in unexpected clipping; and so on. The above method is OK if you're trying to whip out a prototype, or if your stack will be used in a controlled environment and you can ensure that the clipboard contents will always be OK, but I wouldn't use it for production work. >And in a barely related question, is it possible for me to tell from within >a script whether there is a button at a particular point? Basically, you need to write a loop that will check all the buttons and see whether your point is in any of them: on mouseUp put "Click at the point you want..." wait until the mouseClick if pointIsOccupied(the clickLoc) then beep answer "Sorry; there is already a button at that point." exit mouseUp end if -- create the button end mouseUp function pointIsOccupied thePoint repeat with x = 1 to the number of card buttons if thePoint is within the rect of card button x then return "true" end repeat repeat with x = 1 to the number of background buttons if thePoint is within the rect of background button x then return "true" end repeat return "false" -- none of the buttons overlap the point end pointIsOccupied -- ========= jeanne a. e. devoto ======================================== jdevoto@apple.com | You may not distribute this article under a jdevoto@well.sf.ca.us | compilation copyright without my permission. ______________________________________________________________________ Apple Computer and I are not authorized | CI$: 72411,165 to speak for each other. |