Passing Click from Image to Field?

Trevor DeVore lists at
Tue Dec 28 16:58:22 EST 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, \
			min(tLineCount, \
				(pY + vScroll of fld "MyField") / effective textHeight of fld 
"MyField") \
		) into tLine
	put trunc(tLine) into tLine
	if tLine <> tLineCount then add 1 to tLine
	put "Line:" && tLine
end mouseMove

This could probably be optimized a bit but it should do the trick.

Trevor DeVore
Blue Mango Multimedia
trevor at

More information about the use-livecode mailing list