home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #18 / NN_1992_18.iso / spool / comp / sys / mac / hypercar / 3147 < prev    next >
Encoding:
Text File  |  1992-08-18  |  1.5 KB  |  44 lines

  1. Newsgroups: comp.sys.mac.hypercard
  2. Path: sparky!uunet!sun-barr!cs.utexas.edu!sdd.hp.com!elroy.jpl.nasa.gov!orchard.la.locus.com!optimla!mike
  3. From: mike@optimla.aimla.com (Mike Diehr)
  4. Subject: Text insertion point
  5. Message-ID: <1992Aug18.230318.26465@aimla.com>
  6. Sender: news@aimla.com
  7. Nntp-Posting-Host: chondrite
  8. Organization: Philips Interactive Media
  9. Date: Tue, 18 Aug 92 23:03:18 GMT
  10. Lines: 32
  11.  
  12. Is there any way to change the contents of a field without affecting the
  13. insertion point?
  14.  
  15. I have a field that the user types into, and I'd like to have two other
  16. fields that indicate the number of letters and words in the field.
  17.  
  18. I wanted to continually update these values, by using an "On Idle" script.
  19. However, when the field says "put X into me", it moves the insertion point
  20. to that field, and the user can no longer type.
  21.  
  22. A work around that I tried was to do this in the word count field:
  23.  
  24. on SetupField
  25.   repeat with i = 1 to 100
  26.     put i into line i of me
  27.   end repeat
  28. end SetupField
  29.  
  30. on Update
  31.   put the length of field "foo" into X
  32.   set the scroll of me to X * the lineHeight of me
  33. end Update
  34.  
  35. where SetupField is called once, and Update is called on the idle handler.
  36. The trick is, that I am not putting anything into the field, but only
  37. changing it's scroll position, so the text insertion point shouldn't
  38. be changed.
  39.  
  40. However, with this method, strange things happen.  If I select some text and
  41. hit the "delete" key, and then hit return, it tries to execute the
  42. contents of the message box, even if it is closed.
  43.  
  44.