field: click on no char

Ken Ray kray at
Thu Apr 10 22:49:01 CDT 2003

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 text."
    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
Web Site: 

> -----Original Message-----
> From: use-revolution-admin at 
> [mailto:use-revolution-admin at] On Behalf Of 
> erik hansen
> Sent: Thursday, April 10, 2003 4:20 PM
> To: use-revolution at
> Subject: field: click on no char 
> --- Ken Ray <kray at> wrote:
> > Erik, are you trying to know exactly where the
> > user clicked (I mean "in
> > the left margin next to line 3 of the field"),
> > or just whether the user
> > clicked on text or not?
> the areas in a field that have NO text are the
> concern. say my third line has only 20 chars of
> text and the field is wide enough to  handle 80
> chars. click where char 40 would be (if i had
> padded 80 spaces) and you get no reading.
> the user is used to a cursor "snapping" back to 
> the end of the text. 
> the easy solution is just to pad with spaces
> before and after the text. all the editor needs
> to know is that the user clicked on a char before
> or after a string of linked text. there could be
> 1 char or 100 chars between word 1 and word 2.
> the result would be "1 2" in my usage. before
> word 1 is "0 1"
> =====
> erik at
> __________________________________________________
> Do you Yahoo!?
> Yahoo! Tax Center - File online, calculators, forms, and more _______________________________________________
use-revolution mailing list
use-revolution at

More information about the use-livecode mailing list