Trouble with formattedWidth revisited
Cubist at aol.com
Cubist at aol.com
Thu Apr 6 23:11:51 EDT 2006
In a message dated 4/6/06 3:54:09 PM, Graham Samuel <livfoss at mac.com> writes:
>Recently, I wrote:
>> I'm interested in truncating a character string to a certain number
>> of pixels. As part of this process, I put the string into field and
>> check the field's formattedWidth. My script says
>> put the formattedWidth of field "myField" into myTemp
>> I can verify that the string is really there and is not null.
>> The RR docs says:
>>> If you specify a field, the formattedWidth reports the width
>>> required by the field's text.
>> Well, for me sometimes it does, and sometimes it doesn't. When it
>> doesn't, the formattedWidth reports zero. ...
>Sarah Reichelt (thank, Sarah) suggested my problems would go away if
>I made sure the field had its 'dontWrap' property set to true. Well,
>I've done this, and I've made sure there is a genuine font set
>(Lucida Grande) and a genuine text size (10 point), and when I run my
>handler it returns zero. ...
>It's got to be something I'm doing wrong, but I simply can't work out
>what it is.
>
>Any suggestions out there?
I've never played with formattedWidth, myself, but one semi-obvious
possibility leaps to mind. Since you're interested in how many characters can fit
into whatever number of pixels, why not try something in this neighborhood:
put the formattedWidth of char 1 to 15 of field "myField" into myTemp
Hope this helps...
More information about the use-livecode
mailing list