Truncate Text Based On Available Space?

Peter M. Brigham pmbrig at gmail.com
Sun Jun 16 08:55:40 EDT 2013


Sorry about chiming it so late on this thread, but I got several days behind in perusing the list. If you use the templatefield then you would first have to set the properties of the templatefield to the properties of the field you are using, right? Which brings us back to the thread about what exactly "the properties of field 1" contains.

-- Peter

Peter M. Brigham
pmbrig at gmail.com
http://home.comcast.net/~pmbrig


On Jun 12, 2013, at 11:01 PM, J. Landman Gay wrote:

> On 6/12/13 9:57 PM, Monte Goulding wrote:
>> 
>> On 13/06/2013, at 12:47 PM, J. Landman Gay wrote:
>> 
>>> I did this ages ago, like back in MC. I used a real field, but now that I know better I'd use the templatefield instead. It's ugly, but since you can only measure text width from a field, you have to loop. The pseudocode is something like:
>>> 
>>> store the original text somewhere for reference later
>>> put it into a field
>>> repeat until the formattedwidth of the text is <= the column:
>>>  delete last char of the field
>>>  put "..." into last char of the field
>>> end repeat
>>> 
>>> Even with a "real" field it was still pretty fast. Probably would be faster with the templatefield. The "..." isn't three periods, it needs to be the real elipsis character so that the "last" character includes all three visual dots.
>> 
>> Cool... wouldn't it be nice if there was a field property to get it to do that automatically....
> 
> You bet. And while you're at it, make it so we can optionally insert the elipsis into the middle of the string too, like Apple does it. :)




More information about the use-livecode mailing list