Selecting a word

Stuart Milliken stuart_milliken at sil.org
Fri Dec 21 01:19:02 EST 2001


>I am having a problem finding a command to select a word
>and put it into a container...
>I'd like to click on a word, show a rectangle around it (like in
>Hypercard) or color it, and put it into a variables container.


I'm not 100% sure if this is what you want, but the following works in a
field's script for double-clicking on a word in an unlocked field to put the
word in a container.  (For an unlocked field I assume you don't want to
interfere with single-clicking.)

on selectionChanged
  put the ticks into t
  repeat until the mouseClick
     if the ticks - t > the doubleClickInterval then exit to top --SEE NOTE
BELOW
  end repeat
  if the clickChunk = "" then exit to top
  select the clickChunk --OPTIONAL, TO HILITE THE WORD
  put the clickText into someContainer
end selectionChanged

(NOTE: "the doubleClickInterval" gives me a number apparently in
milliseconds, though the documentation says it should be in ticks on a Mac.
Perhaps this is somehow due to my non-Mac (Logitech) mouse. If this is also
the case for you, substitute literal value for a reasonable number of ticks,
like 20.)

If you have a mouse with a right button, the following also works to (right)
single-click (for me anyway):

on mouseUp
  select the clickChunk --OPTIONAL, TO HILITE THE WORD
  put the clickText into someContainer
end mouseUp

This works without specifying a mouse button parameter because, for some
reason, the mouseUp message evidently is only sent to the field if you
right-click and not if you left click.

If the field is locked and you just want to single-click in the normal way
on the word, the above mouseUp handler works too.

Hope this helps,

Stuart Milliken

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.runrev.com/pipermail/use-livecode/attachments/20011221/4a1236b3/attachment.html>


More information about the use-livecode mailing list