leue@galen.crd.ge.com (Bill Leue) (09/12/90)
Here's a couple of probably trivial HC questions. I'm just getting started using Hypertalk, so please be patient if these have been hashed over before: 1. I can't find any way to either detect or simulate a double click. Is there any reasonable way? For instance, it would be useful to be able to say choose eraser tool double click to erase the entire picture. (Yes, I know you can say "doMenu Select All" followed by "Cut Picture".) Just asking. As far as detecting a double click, I suppose it might be possible to get the time in ticks on each click, then see if two clicks (at the same coordinates, more or less) were separated by some minimum number of ticks... hmmm, sounds tedious. 2. On a recent test stack I built, I implemented a little compass-like widget whose "indicator" I update using the drawing tools in a script. As I read the various Hyperscript docs, it seems that any changes I make to a card by using the drawing tools are auto-saved by HC. This means the stack is continually growing, right? What's the best way to keep the stack size under control: keep track of the freesize and compact the stack whenever it gets too big? Or can the "Revert" menu command be used in a script? My guess is that it would be painfully slow to "revert" each time you draw something on a card. 3. Has anyone come up with a clever way to simulate arbitrarily-shaped buttons, a la Supercard? Again, I could define polygonal regions and then do geometric tests on the mouse position, but this seems on first glance to be slow and complex to implement with any kind of generality. -Bill Leue leue@crd.ge.com
Griffiths.R@AppleLink.Apple.com (Rob Griffiths) (09/12/90)
There have been a couple of recent questions concerning double clicking on objects. As far as I know, there is no truly easy way to check this...However, I normally use the following: on mouseup put the ticks into TM repeat until the mouseclick if (the ticks - TM) > 20 then -- too much time has transpired, cancel the handler. -- or, alternatively, perform a single-click action. -- (vary the double-click response speed by changing the "20" -- to another number, either higher or lower.) exit mouseup end if end repeat -- if we get here, user has double clicked -- so, put double-click action here! end mouseup Just attach this to the object you wish to check, and add the code to perform whatever actions you desire. One nice side benefit is that you can make a single click perform one action (for instance, display a menu), and a double click another (go directly to some card). If anyone has a more elegant solution (quicker? shorter?), I'd love to see it! rob
greggor@Apple.COM (Greg L. Anderson) (09/12/90)
In article <11792@crdgw1.crd.ge.com> leue@galen.crd.ge.com (Bill Leue) writes: >3. Has anyone come up with a clever way to simulate >arbitrarily-shaped buttons, a la Supercard? Again, I could >define polygonal regions and then do geometric tests on the >mouse position, but this seems on first glance to be slow >and complex to implement with any kind of generality. Yes, I've written polybutton XFCNs & the response time is quite good. I will be posting the code pretty soon. The main problem is that the buttons MUST be transparent. (If anyone knows how to invoke an XFCN on an update event, I want to hear about it!) -- ___\ /___ Greg Anderson ___\ /___ \ \ / / Advanced Technology Group \ \ / / \ /\/\ / Apple Computer, Inc. \ /\/\ / \/ \/ greggor@apple.com \/ \/
bc@Apple.COM (bill coderre) (09/12/90)
In article <44719@apple.Apple.COM> greggor@Apple.COM (Greg L. Anderson) writes: |The main problem is that the buttons MUST be transparent. (If anyone knows |how to invoke an XFCN on an update event, I want to hear about it!) Hypercard 2.0 provides an XCMD callback hook to prefilter the event queue, called SendHCEvent. Its utility is very limited, though, and the documentation is even more limited. I really have no further info in the subject, but do have a look-see. Maybe it will do enough for you. bill coderre private consultant with a passion for veal saltimboca
bc@Apple.COM (bill coderre) (09/12/90)
Bill Leue: |1. I can't find any way to either detect or simulate a double |click. Is there any reasonable way? For instance, it would |be useful to be able to say | choose eraser tool | double click |to erase the entire picture. (Yes, I know you can say |"doMenu Select All" followed by "Cut Picture".) Just asking. Sending a double click is possible, if you are sending it to a button or a field. You can do it by writing click at the loc of cd btn foo click at the loc of cd btn foo This method doesn't work with tools. I don't know why not. That's Just The Way It Is. |As far as detecting a double click, I suppose it might be possible |to get the time in ticks on each click, then see if two clicks |(at the same coordinates, more or less) were separated by some |minimum number of ticks... hmmm, sounds tedious. Well, there are a number of cases that have to be accounted for. But, once you do them, you'll be so pleased with your work.... I will repost a script to detect double-clicking the right way shortly. Please be patient. |2. On a recent test stack I built, I implemented a little |compass-like widget whose "indicator" I update using the |drawing tools in a script. As I read the various Hyperscript |docs, it seems that any changes I make to a card by using the |drawing tools are auto-saved by HC. This means the stack is |continually growing, right? What's the best way to keep the |stack size under control: keep track of the freesize and |compact the stack whenever it gets too big? Well, Hypercard will naturally re-use heap space if at all possible, but your stack will grow somewhat when used. (I've found that my stacks grow 30 or 40 K right away and then don't grow much more.) The best solution, I think, is to compact the stack on closing. But remember to check "the diskspace" and make sure there is room enough for another temp copy of the stack during compaction, or your naive user will be presented with an -- perish the thought! -- error message. bill coderre private consultant, not apple spokeman.
rmh@apple.com (Rick Holzgrafe) (09/13/90)
In article <10164@goofy.Apple.COM> Griffiths.R@AppleLink.Apple.com (Rob Griffiths) writes: > on mouseup > put the ticks into TM > repeat until the mouseclick > if (the ticks - TM) > 20 then > -- too much time has transpired, cancel the handler. > -- or, alternatively, perform a single-click action. > -- (vary the double-click response speed by changing the "20" > -- to another number, either higher or lower.) > exit mouseup > end if > end repeat > -- if we get here, user has double clicked > -- so, put double-click action here! > end mouseup > > Just attach this to the object you wish to check, and add the code to > perform whatever actions you desire. One nice side benefit is that you > can make a single click perform one action (for instance, display a menu), > and a double click another (go directly to some card). Just a friendly warning... the Apple Thought Police will getcha if you break a basic rule about clicking: NEVER WAIT FOR THE SECOND CLICK. You should do something immediately when you receive the first click, then something in addition when you receive the second. That way response to every click can be as fast as possible. The handler above, on the other hand, twiddles its thumbs while waiting for further orders from the user. (I know that HyperCard is slow enough that the difference may not be so noticable. But Macs are getting faster, and HC 2.0 is supposed to really zip along. And nobody likes to wait!) Instead, I'd suggest something like the following, placed in the script of your stack. (Forgive any syntax errors, this is typed on the fly.) function isDoubleClick global lastClickTime, lastClickItem put the ticks into TM if TM - lastClickTime < 20 and the id of the target is lastClickItem then return true else put TM into lastClickTime put the id of the target into lastClickItem return false end if end isDoubleClick Then do something like this in the script of each double-clickable item: on mouseup if isDoubleClick then -- do double-click stuff else -- do single-click stuff end if end mouseUp Now, don't flame me about any of this - I don't work for the ATP. I just don't like seeing people dragged screaming from their beds in the middle of the night. :-) :-) :-) ========================================================================== Rick Holzgrafe | {sun,voder,nsc,mtxinu,dual}!apple!rmh Software Engineer | AppleLink HOLZGRAFE1 rmh@apple.com Apple Computer, Inc. | "All opinions expressed are mine, and do 20525 Mariani Ave. MS: 3-PK | not necessarily represent those of my Cupertino, CA 95014 | employer, Apple Computer Inc."
mxmora@unix.SRI.COM (Matt Mora) (09/13/90)
In article <10179@goofy.Apple.COM> rmh@apple.com (Rick Holzgrafe) writes: > >Just a friendly warning... the Apple Thought Police will getcha if you >break a basic rule about clicking: NEVER WAIT FOR THE SECOND CLICK. You > >Instead, I'd suggest something like the following, placed in the script of >your stack. (Forgive any syntax errors, this is typed on the fly.) > >function isDoubleClick > global lastClickTime, lastClickItem > put the ticks into TM > if TM - lastClickTime < 20 and the id of the target is lastClickItem then ^^ What? stuff deleted > >Now, don't flame me about any of this - I don't work for the ATP. I just >don't like seeing people dragged screaming from their beds in the middle >of the night. :-) :-) :-) ATP is going to come and revoke your programming license for using a hardcoded number for the double click time interval. Hypercard already breaks enough Human Interface rules without the help from crazy DTS engineers. :-) Included is a XFCN that gets the correct double click time from the parameter ram. > >========================================================================== >Rick Holzgrafe | {sun,voder,nsc,mtxinu,dual}!apple!rmh >Software Engineer | AppleLink HOLZGRAFE1 rmh@apple.com >Apple Computer, Inc. | "All opinions expressed are mine, and do >20525 Mariani Ave. MS: 3-PK | not necessarily represent those of my >Cupertino, CA 95014 | employer, Apple Computer Inc." Boy, and you work at apple. :-) (This file must be converted with BinHex 4.0) :%'4LE'0XD@0VG'PYC5jcDA3!8dP8)90*9#%!!!!!!RX!!!!!99*6593K!!%!!!* lFNaKG3%!!!!!!!!!!J!44%*-3faTBfY8D@eP,RKQBfi!!!!!!!!!!@!$!!C!J0A 1!"X4-J!,eCJ!'hVH!3i!)!%!!3i!)!!!!!!!'a&-2cmr2cmr2cm"!+-9!b@M&3- R!!!#M`!!!!!!!!(e!!!!!-Yk!!!!!!!!!!#f43!!"!J)3!#8J!%1"[a"F!+MIrm )!($JM##!#BdJ5R5!cZ)%4"SM%"(#C!LE0'2@8%R6TS`,2'E'Z"&!m)I0QcBYiX4 TXDI2R`&(94K3`UH!4`)*3!4K!!BML`%+,$@!!`C8!e0rq)"kB1S4Ee!46%hL`Z) !G91Ec,'i30G8+Zjk+Sd))--SRaVVpZSC)#q(F$d&j1e3L'!!*Q!F"-4LC)J6!)" m"Y(hced)C!QFJ4')iB8#%@m!)#!4QJ'-&`!Jd!!J3B-X!@3%8!JJ34JB!4+d49( fMaqX!#5qJ2Mbj"d!"8kJ1E(L$pi,"L$FL"lLVMQF(b+`48(@'i9d"N'U`dZ""!# 8((`!(!$!j!8,!%L'1i(8JJd!1+P4I((LC6L8*mP"%F389$bK44&5,2F20-pj"`! $+8L(J(RK,8JH!&5J0a&llX%R(b64TIB$$`"mJ)3E#lk!J"0Z8D%IIri"U&`9644 )B),--B2%13-J`%*C#+"J4"C2Z)#,!2#iB+)ErM$cJJ%[(-$L2jCJmF5)!2acBT0 EXM1P!d3qfH@8-+6`"3!NI3-"-2bjm)N6GBa8%K0*$,(%FJ'p!158S,6jCKe0"*' %%b!8#J*#""Q%N!"#!$#8!"')$-!S"`$)X&KMM`@N!'3r*E!,#Jb3!#%''f1FP") G,*8"&a%!!!:-- ___________________________________________________________ Matthew Mora | my Mac Matt_Mora@sri.com SRI International | my unix mxmora@unix.sri.com ___________________________________________________________
rmh@apple.com (Rick Holzgrafe) (09/14/90)
In article <16194@unix.SRI.COM> mxmora@unix.SRI.COM (Matt Mora) writes: > ATP is going to come and revoke your programming license for using a hardcoded > number for the double click time interval. I just KNEW somebody would call me on that. I KNEW it, I KNEW it, I KNEW IT!!!! (stomp, stomp, stomp, sulk... :-) > Hypercard already breaks enough > Human Interface rules without the help from crazy DTS engineers. :-) I am not a crazy DTS engineer. I am a crazy development engineer. (And FIERCELY proud of it, sirrah!) > Included is a XFCN that gets the correct double click time from the parameter > ram. Ahhh! Many thanks. The correct solution. In truth, I used a constant for want of any (quick simple) way to get the double-click time into a script... and here are my prayers answered: somebody else did the work! ========================================================================== Rick Holzgrafe | {sun,voder,nsc,mtxinu,dual}!apple!rmh Software Engineer | AppleLink HOLZGRAFE1 rmh@apple.com Apple Computer, Inc. | "All opinions expressed are mine, and do 20525 Mariani Ave. MS: 3-PK | not necessarily represent those of my Cupertino, CA 95014 | employer, Apple Computer Inc."