Path: utzoo!attcan!uunet!dino!ceres!zaphod.mps.ohio-state.edu!uakari.primate.wisc.edu!gdavis From: gdavis@primate.wisc.edu (Gary Davis) Newsgroups: comp.sys.mac.hypercard Subject: Re: selecting from a scrollable field Message-ID: <1885@uakari.primate.wisc.edu> Date: 15 Mar 90 21:17:29 GMT References: <1990Mar15.052929.5942@lsuc.on.ca> Sender: news@primate.wisc.edu Reply-To: gdavis@primate.wisc.edu Lines: 39 From article <1990Mar15.052929.5942@lsuc.on.ca>, by dave@lsuc.on.ca (David Sherman|LSUC|Toronto): - abdenour@mist.CS.ORST.EDU (Abdennour A. MOUSSAOUI) writes: --I have a list of numbers let us say from 1-1000. if I place them --in a scrollable field (one number per line), is it possible --write a script so that when a user click on a number then I will know --on which one he click on? - - The below is what I use. As well as being simple, it avoids the - problems of some of the other posted solutions when the line is - long enough to wrap around to a second line on the field. - - Make sure the field is locked. - - on mouseUp - set the lockText of me to false -- to allow selecting - click at the clickLoc - click at the clickLoc - -- now the word clicked on is selected - set the lockText of me to true -- so the user can't muck around - select the selectedLine -- optional, to highlight the whole line clicked on - put word 2 of the selectedLine into lineNumber - go card (line lineNumber of me) -- or whatever - end mouseUp This solution works well when you have the possibility of wrapped lines, but it is noticeably slower than calculating the line clicked from the click point as others have suggested. If you have a scrolling list of just numbers from 1 to 1000 then you presumably don't need to worry about wrapped lines. To get the contents of the selected line you can also just say value of the selectedLine instead of line (word 2 of the selectedLine) of me Gary Davis