home *** CD-ROM | disk | FTP | other *** search
- 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
- From: jpugh@apple.com (Jon Pugh)
- Newsgroups: comp.sys.mac.hypercard
- Subject: Re: Text insertion point
- Message-ID: <jpugh-190892110348@wolverine.apple.com>
- Date: 19 Aug 92 18:09:16 GMT
- References: <1992Aug18.230318.26465@aimla.com>
- Sender: news@gallant.apple.com
- Followup-To: comp.sys.mac.hypercard
- Organization: Apple Computer, Inc.
- Lines: 41
-
- In article <1992Aug18.230318.26465@aimla.com>, mike@optimla.aimla.com (Mike
- Diehr) wrote:
- >
- > Is there any way to change the contents of a field without affecting the
- > insertion point?
- >
- > I have a field that the user types into, and I'd like to have two other
- > fields that indicate the number of letters and words in the field.
- >
- > I wanted to continually update these values, by using an "On Idle" script.
- > However, when the field says "put X into me", it moves the insertion point
- > to that field, and the user can no longer type.
-
- No, there is no way to change the contents of a field without affecting the
- insertion point.
-
- You can, however, save the location of the insertion point and set it after
- you have mucked with the field. This has some dangerous aspects though and
- I wouldn't recommend it except in limited circumstances.
-
- The function "the selectedChunk" returns the chunk expression for the
- current
- selection. You can simply say:
-
- get the selectedChunk
- put gunk into fld "Foo"
- select it
-
- However, if you have changed the text, the selectedChunk may not be valid
- anymore, or it may describe a different chunk of text, or a different
- insertion point. This is worse than eliminating the insertion point, IMHO.
-
- Of course, you can parse the chunk expression and update it based on what
- you have done to the text, but you're starting to get pretty hairy and
- speed
- will become an issue.
-
- Instead, I recommend updating your line and count fields on the closeField
- message. It's cleaner and simpler.
-
- Jon
-