Caret/insert position in field

Michael Kann mikekann at yahoo.com
Fri May 14 16:20:39 EDT 2010


Jeff,

Here's a way to suck out info from the cursor position in a fld. Perhaps it will give you an idea or two.

on mouseUp
put numToChar(255) into marker
set the itemDelimiter to marker
put marker after the selection
----------------------------------
put fld 1 into v // typing text
----------------------------------
-- use v to find position in text
----------------------------------
delete item 2 of v
put num of chars in v into insert_pos
put num of chars in v & cr after h
put num of words in v & cr after h
put num of lines in v & cr after h
----------------------------------
put the last line of v into vv
----------------------------------
put num of chars in vv & cr after h
put num of words in vv & cr after h
-----------------------------------
put the last word of v into vvv
put num of chars in vvv & cr after h
put h into fld 2 // output fld
-----------------------------------
--get fld 1 back to original state
-----------------------------------
delete char (insert_pos + 1) of fld 1
-----------------------------------
end mouseUp


      



More information about the use-livecode mailing list