Trouble with formattedWidth

Sarah Reichelt sarah.reichelt at gmail.com
Tue Apr 4 23:05:02 EDT 2006


On 4/5/06, Graham Samuel <livfoss at mac.com> 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. I guess this is something
> to do with me forgetting to give any specific attributes of font or
> type size to the field (or the string), but what rules then apply? I
> am finding this very mysterious. I am pretty sure I can cook up a
> foolproof recipe for getting the zero, but before I do maybe someone
> could explain what is likely to be happening here.

I have used this method several times with no problems, but you must
make sure the field's dontWrap is set to true.

Cheers,
Sarah



More information about the use-livecode mailing list