Truncate Text Based On Available Space?

J. Landman Gay jacque at hyperactivesw.com
Wed Jun 12 23:01:22 EDT 2013


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. :)

-- 
Jacqueline Landman Gay         |     jacque at hyperactivesw.com
HyperActive Software           |     http://www.hyperactivesw.com




More information about the use-livecode mailing list