field: click on no char
erikhans08 at yahoo.com
Fri Apr 11 00:55:00 CDT 2003
we're not in HC anymore!
--- Ken Ray <kray at sonsothunder.com> wrote:
> Ok, Erik, ready for some real hackin'?
> Step 1: Set the margins of your field so that
> the user can't click to
> the left or above any text (I set the margin to
> 2). (If you need the
> user to see a margin, make this field
> transparent and place it on top of
> another locked field that is a bit bigger to
> simulate a margin.)
> Step 2: Set the lockText of the field to true.
> (You probably already did
> Step 3: We're going to take advantage of the
> formattedText() function,
> that inserts CRs where lines wrap in text
> fields by temporarily putting
> the formattedText into the field, seeing where
> the user clicked, and
> then resetting the text to what it was. We'll
> use the mouseCharChunk and
> mouseLine functions instead of the
> clickCharChunk and clickLine
> functions because they're the ones that work.
> Put the following script into your field:
> on mouseUp
> put me into tText
> put the formattedText of me into me
> put the mouseCharChunk into tChunk
> put the mouseLine into tLine
> put tText into me
> if tChunk <> "" then
> put "The user clicked on " & tChunk
> if tLine <> "" then
> put "The user clicked after the end of "
> & tLine
> put "The user clicked past the end of the
> end if
> end if
> end mouseUp
> In my testing, I had a field whose text wrapped
> like this:
> Now is the time for all good men to
> come to the aid of their party.
> Here's another test of the second
> When I clicked between "good" and "men", I got:
> The user clicked on char 29 to 29 of field 1
> When I cliked after the "." in "party."
> (between it at the right edge of
> the field), I got:
> The user clicked after the end of line 2 of
> field 1
> When I clicked below the word "paragraph"
> (between the baseline of it
> and the bottom of the field), I got:
> The user clicked past the end of the text.
> Hopefully you'll be able to tweak this for your
> own purposes.
> Have fun!
> Ken Ray
> Sons of Thunder Software
> Email: kray at sonsothunder.com
> Web Site: http://www.sonsothunder.com/
erik at erikhansen.org http://www.erikhansen.org
Do you Yahoo!?
Yahoo! Tax Center - File online, calculators, forms, and more
More information about the use-livecode