Jump to content

suppress a frame based on the copyfit of another frame


Recommended Posts

I am trying to switch which frame contains copy, based on a copyfit.

If copy fits in Frame A ("textblock"), then Frame B ("textblocklong") is suppressed.

If copy does not fit in Frame A, then Frame A is suppressed and Frame B is used.

Copy will always fit in Frame B.

 

I cannot figure out to get this rule to put copy into Frame B("textblocklong") only when FrameA !Copyfit

 

It does manage to suppress frame B when copyfits

It does manage to suppress frame A when !copy does not fit

It does not manage to put content into Frame B when !copy does not fit

 

This novice needs some help with this rule.

 

if (FusionPro.Composition.CurrentFlow.name == "textblock")

{

if (!Copyfit(new MagnifyAttributes("text", 100, 100, 0, 0)))

FusionPro.Composition.CurrentFlow.content = "";

}else{

 

(FusionPro.Composition.CurrentFlow.name == "textblocklong")

FusionPro.Composition.CurrentFlow.content = "";

}

 

}

Link to comment
Share on other sites

In the OnCopyfit callback rule, you can't modify the contents of any text frame, or suppress a frame, other than the one being currently processed.

 

What you can do, in OnRecordStart, is use the FusionProTextMeasure object to determine whether the text would fit into a particular frame, then set each frame's suppress property, or its text contents, as appropriate. This will work fine as long as the (smaller) frame doesn't wrap its text around any other frames.

Link to comment
Share on other sites

Can you help me with that OnRecordStart text Measure rule to suppress the frame? I very novice here and do not know how to write that. How do you write the text measure to determine if copy does not fit in the frame?

 

var tm = new FusionProTextMeasure;

tm.useTags = true;

tm.CalculateTextExtent(Resource(BCText));

var tmWidth = tm.textWidth;

 

if (tmWidth > "XX??") //if text exceeds frame

{

FindTextFrame("textblock").suppress = true;

FindTextFrame("textblocklong").suppress = false;

}

else

{

FindTextFrame("textblock").suppress = false;

FindTextFrame("textblocklong").suppress = true;

}

 

Thanks for your help.

Link to comment
Share on other sites

Something like this:

var smallFrame = FindTextFrame("textblock");
var largeFrame = FindTextFrame("textblocklong");

var TM = new FusionProTextMeasure;
TM.maxWidth = smallFrame.GetSettableTextWidth();   
var err = TM.CalculateTextExtent(Resource(BCText).content);
if (err && err != -1)
   throw "Error measuring text: " + TM.messages;

var fitsInSmallFrame = TM.textHeight < smallFrame.GetSettableTextHeight();
smallFrame.suppress = !fitsInSmallFrame;
largeFrame.suppress = fitsInSmallFrame;

Edited by Dan Korn
typo
Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...