Passing Click from Image to Field?
J. Landman Gay
jacque at hyperactivesw.com
Wed Dec 29 01:03:12 EST 2004
On 12/28/04 4:26 PM, Scott Rossi wrote:
> Recently, J. Landman Gay wrote:
>
>
>>This will calculate a line number based on the click location
>
>
> Dude, you rule. Your function with bit of modification works:
>
> on mouseUp
> put clickToLine(tFldNum)
> end mouseUp
>
> function clickToLine tFldNum
> put item 2 of the rect of fld tFldNum into T
> put the effective textHeight of fld tFldNum into H
> put (the scroll of fld tFldNum) div \
> (the effective textHeight of fld tFldNum) into S
> return (the clickV - T) div H + 1 + S
> end clickToLine
Sorry, I meant to account for the scroll but forgot to add it to my
function. An even shorter way to do this is to just subtract the scroll
from the top before figuring out the line number. And come to think of
it, we don't need to use "item 2 of the rect" of the field, we can just
use the "top":
function clickToLine tFldNum
put the top of fld tFldNum - the scroll of fld tFldNum into T
put the effective textHeight of fld tFldNum into H
return (the clickV - T) div H + 1
end clickToLine
--
Jacqueline Landman Gay | jacque at hyperactivesw.com
HyperActive Software | http://www.hyperactivesw.com
More information about the use-livecode
mailing list