home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #18 / NN_1992_18.iso / spool / comp / sys / mac / hypercar / 3163 < prev    next >
Encoding:
Internet Message Format  |  1992-08-19  |  2.0 KB

  1. Path: sparky!uunet!charon.amdahl.com!pacbell.com!mips!swrinde!zaphod.mps.ohio-state.edu!uakari.primate.wisc.edu!ames!data.nas.nasa.gov!taligent!apple!mumbo.apple.com!gallant.apple.com!wolverine.apple.com!user
  2. From: jpugh@apple.com (Jon Pugh)
  3. Newsgroups: comp.sys.mac.hypercard
  4. Subject: Re: Text insertion point
  5. Message-ID: <jpugh-190892110348@wolverine.apple.com>
  6. Date: 19 Aug 92 18:09:16 GMT
  7. References: <1992Aug18.230318.26465@aimla.com>
  8. Sender: news@gallant.apple.com
  9. Followup-To: comp.sys.mac.hypercard
  10. Organization: Apple Computer, Inc.
  11. Lines: 41
  12.  
  13. In article <1992Aug18.230318.26465@aimla.com>, mike@optimla.aimla.com (Mike
  14. Diehr) wrote:
  15. > Is there any way to change the contents of a field without affecting the
  16. > insertion point?
  17. > I have a field that the user types into, and I'd like to have two other
  18. > fields that indicate the number of letters and words in the field.
  19. > I wanted to continually update these values, by using an "On Idle" script.
  20. > However, when the field says "put X into me", it moves the insertion point
  21. > to that field, and the user can no longer type.
  22.  
  23. No, there is no way to change the contents of a field without affecting the
  24. insertion point.
  25.  
  26. You can, however, save the location of the insertion point and set it after
  27. you have mucked with the field.  This has some dangerous aspects though and
  28. I wouldn't recommend it except in limited circumstances.
  29.  
  30. The function "the selectedChunk" returns the chunk expression for the
  31. current
  32. selection.  You can simply say:
  33.  
  34. get the selectedChunk
  35. put gunk into fld "Foo"
  36. select it
  37.  
  38. However, if you have changed the text, the selectedChunk may not be valid 
  39. anymore, or it may describe a different chunk of text, or a different
  40. insertion point.  This is worse than eliminating the insertion point, IMHO.
  41.  
  42. Of course, you can parse the chunk expression and update it based on what
  43. you have done to the text, but you're starting to get pretty hairy and
  44. speed
  45. will become an issue.
  46.  
  47. Instead, I recommend updating your line and count fields on the closeField
  48. message.  It's cleaner and simpler.
  49.  
  50. Jon
  51.