here's a challenge

Monte Goulding monte at sweattechnologies.com
Wed Aug 27 19:19:00 EDT 2003


***************
Well, I think it's a challenge anyway.

I have a field with text from a story.  It's just basic text split into one
or more paragraphs.  I need to come up with a way to create what we call a
reading guide, which would basically consist of a rectangular box that
follows the mouse pointer up and down will inside of the text field.  The
trick is that the box must "snap" into place so to speak, so that the
current line of text is vertically centered within the box.  Students will
be reading the text and the box cannot wander if the mouse pointer is not
exactly on the line of text.  I am using fixedLineHeight for the text field,
and I think that will come into play somewhere (the distance to move the box
up and down?).  What I'm not sure of is which messages I need to handle to
create this kind of behavior.

Does anyone have any ideas?  Have I even made sense?  I can try again to
explain it if necessary.
***************

Hi Chris

As long as it's not a scrolling field then you should be able to do
something like this:

 constant kLeft = the left of your box, kRight = the right of your box

 put (item 2 of the mouseLoc - the top of fld 1) div the lineHeight of fld 1
into tTop
 set the rect of grc "box" to kLeft,tTop,kRight,tTop+the lineHeight of fld 1


Should work ...

Cheers

Monte




More information about the use-livecode mailing list