Grouped Fields and the formattedHeight

Igor Couto igor at pixelmedia.com.au
Wed Jun 25 07:30:56 EDT 2003


1) Make a new stack. Place 3 fields in it ("fld1", "fld2", "fld3"), and 
enter a couple of chars of text in them.

2) Group the fields ("grp1").

At this stage, note that 'textFont' and 'textSize' for all fields as 
well as the group is EMPTY.

Now, following the manual, if I change the font and size for the GROUP, 
that change should be reflected in the fields... So:

3) Type in the message box:

set the textFont of group "grp1" to "myFavouriteFont" - use any font 
you like

The font on all 3 fields will change. Now, let's change the size - to 
something obviously too large to fit in our fields:

4) set the textSize of group "grp1" to 36

The text in the fields DOES change size. The text is now, however, too 
high to fit into the fields. So, in order to find out how high the 
fields have to be, we'll use the FORMATTEDHEIGHT property:

5) put the formattedHeight of field "fld1" of group "grp1"

The reported formattedHeight is '28'. A bit odd, considering that the 
font size is 36...

Ok, so let's resize the fields to the proposed height of 28:

6) Using the multi-line message box, type:

repeat with x = 1 to 3
	set the height of field x of group "grp1" to 28
end repeat

Hmmm, what happened here? The fields resized, but the text DOES NOT 
FIT... How come? Did I use the right height? Let's check:

7) put the formattedHeight of field "fld1" of group "grp1"

The result is now 62!!! - note that we have NOT changed either the 
font, nor the size, since the first time we got the reported 
formattedHeight. Somehow, it was 28, and now it is 62... Hmmm.

So what happened was that the FIRST time I set the textSize property of 
the GROUP, the change in point size was not seen at the field's level - 
even though Revolution showed the font in the appropriate size in the 
screen. When a SECOND change was applied to the field (changing the 
height of the field itself), then Revolution suddenly realised that the 
point size of the field had, indeed, changed.

This happens consistently. A second change has to be made to the field 
for Revolution to realise that the formattedHeight for the field has 
changed...

But wait, there's more!  Remember that our group now has both a 
'textFont' and a 'textSize' property, which the fields should be using. 
Ok, let's 'remove' the textFont of the group:

8) set the textFont of group "grp1" to empty

Hmmm, the text has disappeared... Actually, it has not disappeared at 
all. To find out what happened, try this:

9) put the textSize of group "grp1"

It returns EMPTY - ie., when we set the 'textFont' to empty, Revolution 
decided that we also wanted to set the 'textSize' to empty...

However, the textHeight of the fields has NOT been updated - so we 
actually have 11 point text sitting on a 36 point baseline, and that is 
why it looks like the text has disappeared. Again, we must make SOME 
CHANGE to the fields, for Revolution to realise what it has done...

Again, this is reproducible every time. So, in recap, 2 problems:

PROBLEM 1
When changing the textSize of a GROUP, Revolution does not seem to 
realize that the formattedHeight for the fields inside the group has 
changed, and reports the wrong number.

PROBLEM 2
When setting the textFont of a GROUP to empty, Revolution seems to also 
set the 'textSize' of the group to empty at the same time...

Is there something basic I'm missing, or are these bugs? I've carefully 
searched the documentation for everything I could find on textSize, 
textFont, formattedHeight, etc., but nothing I found was able to shed 
any light on this behaviour.

I know it is easy enough to write a couple of extra lines of script and 
get around this behaviour - which is what I've already done - but I 
didn't want to 'dirty' my code if it is not necessary, or if I had 
actually misunderstood the way things are supposed to work...

Any guidance will be much appreciated!

Regards,


--
Igor
----------------------------------
igor at pixelmedia.com.au
----------------------------------




More information about the use-livecode mailing list