Passing Click from Image to Field?
lists at mangomultimedia.com
Tue Dec 28 15:58:22 CST 2004
On Dec 28, 2004, at 1:13 PM, Lynch, Jonathan wrote:
> If the list field has a set textheight, then you could calculate the
> distance from the top of the listfield to item 2 of the mouseloc, then
> divide that distance by the list fields textheight, and round it. That
> will give you the line number above which you clicked. Then, you can
> select that line number in the list field.
Great idea. It reminded me that I had some code sitting around that
did this. This takes into account the vertical scroll of the field and
won't return a line number less than 1 or greater then the number of
lines in the field.
on mouseMove pX, pY
put number of lines of text of fld "MyField" into tLineCount
subtract top of fld "MyField" + borderWidth of fld "MyField" from pY
put max(0, \
(pY + vScroll of fld "MyField") / effective textHeight of fld
) into tLine
put trunc(tLine) into tLine
if tLine <> tLineCount then add 1 to tLine
put "Line:" && tLine
This could probably be optimized a bit but it should do the trick.
Blue Mango Multimedia
trevor at mangomultimedia.com
More information about the use-livecode