Expand my Community achievements bar.

Maximum font size script

Avatar

Level 2

Howdy all!  Have a tricky question. Using LiveCycle ES 8.2

Working on a form, I've got a pair of linked text fields (global data linked).

These text fields are static in size, but I need the values typed into them to shrink when it fills up the visible area of the text field.  I can't set the value font size to 0pt from the start.  It makes the initial font size too big for the value.  The font size needs to remain at 16 pt until the value fills up the field's visible area, then it needs to switch over to 0pt (hence triggering a full event).

I've tried using a full event with the following code;

  1. this.font.size = "0pt";

But it won't fire.  I wonder if there is a limitation to the what the full event can trigger.  I can use the change event or even the exit event if I have to.

I've also tried a calculate event with the following script:

  1. if (this.rawValue.length > 48) {
  2.      this.font.size = "0pt";
  3. }
  4. else {
  5.      this.font.size = "16pt";
  6. }

But this did not fire as well.  And yes, I have the scripting set to Javascript...not Formcalc.


Any suggestions?

23 Replies

Avatar

Level 2

It does for the name fields.  It's the title fields which are still troublesome.

After looking at it further, I wouldn't have an issue with making TitleField[0] expand vertically to fit the multiple lines of text.  The idea being to do what you said.  Use the initial height of the field to limit the auto font size when the title is only one line, then have it expand to two lines when the title is long enough.  Just not sure how to accomplish it.  I've never used expand height to fit before. 

Avatar

Level 2

Using the script you gave me for the change event (xfa.resolveNode("TitleField0").rawValue = xfa.event.newText),

I decided to try a different approach.  Since the change event on TitleField1 will now change the rawValue on TitleField0, I thought maybe if I put the following script in the change event on TitleField1 , it would trigger onto TitleField0 correctly.  So far it hasn't, but maybe I'm writing it wrong?

if (form1.Card_order_form.Proof_card.TitleField1.rawValue.length < 36)

    {

    form1.Card_order_form.Proof_card.TitleField0.font.size = "9pt";

}

else

    {

    form1.Card_order_form.Proof_card.TitleField0.font.size = "0pt";

}