Path: utzoo!utgpu!jarvis.csri.toronto.edu!mailrus!wuarchive!psuvax1!psuvm!cunyvm!byuvax!taylorj From: taylorj@yvax.byu.edu Newsgroups: comp.sys.mac.hypercard Subject: Selecting text (or "ClickLine version 5.1") Message-ID: <866taylorj@yvax.byu.edu> Date: 23 Oct 89 05:06:58 GMT Lines: 38 In somebody's response to somebody else's question about selecting text in a locked field, a formula was given to figure out which line of the field was clicked on. This prompted me to offer up the following for public consumption. A while ago there was a "clickLine" function that floated around (various incarnations have appeared as "clickedLine", "lineNumber" and so on). This function had a bug in it and was quickly replaced by a corrected version. Then a new improved "universal" version appeared in the Developer's Stack which accounted for scrolling fields. I improved it yet again to handle fields with wide margins. So if you want a handy little function to tell you which line of a field was clicked on, here's the best one I know of: -- Returns the number of the line clicked on in the target field -- Accounts for scrolling fields and wide margins function clickLine put the clickV - the top of the target into lineV if the style of the target = "scrolling" then add the scroll of the target to lineV if the wideMargins of the target then subtract 4 from lineV return lineV div the textHeight of the target + 1 end clickLine Here's an example of how to use it in the script of a locked field: -- Select the line that was clicked on on mouseUp select line clickLine of me end mouseUp If anyone has any additions or improvements to this script, please pass them on. Jim Taylor Microcomputer Support for Curriculum | Brigham Young University | Bitnet: taylorj@byuvax.bitnet 101 HRCB, Provo, UT 84602 | Internet: taylorj@yvax.byu.edu