Determining exact location within a field

Dar Scott dsc at swcp.com
Thu Feb 26 14:22:43 EST 2004


On Thursday, February 26, 2004, at 09:42 AM, Dan Soneson wrote:

> Does anyone know of a way to find the location of a specific spot 
> within a text field? I am interested in developing a module that will 
> allow me to construct a fill-in-the-blank activity. My thought is to 
> construct a text in a field and mark the words that I want to replace 
> in some way (precede them with a special character). Then I want to 
> construct a button with a script that finds the words with this 
> character in the text and replaces them with a space. Over this space 
> I want to create a field into which users can enter the missing word. 
> It would be nice to automate this process and to be able to know 
> exactly where to place the new field, how large to make it, etc. But I 
> cannot figure out the placement issue.

I have been considering this.  Marking has been a problem for my use.  
In your case it may not.

I don't think you can replace the words with a space, since that will 
shift characters after that and make your fill-in fields at the wrong 
place.  I would think you want to cover the entire word with the 
fill-in field and it should take up the same space.

Ken Ray suggested selecting each of those words and then using the 
selectedLoc.  You may need to do all this in preOpenCard to keep all 
that invisible.  You might want to use formattedHeight to get the 
rectangle.

I have been considering somehow using the formattedHeight of some 
subsets of characters to help get info instead of selectedLoc.  I'm not 
sure how that will work.

Part of the problem is marking the locations.  You have solved that 
with a special character and with covering the point.  It would be a 
nice if there was a way to annotate text without making a link.  Hmmm.  
In your case, since you are covering the text, the link might be OK.  
In my case, I can mess the text.

You may want to keep to a word to avoid splitting the fill-in field.  
Or turn off wrap.

Dar Scott



More information about the use-livecode mailing list