What's the best way to detect that text fits into ContainerControllers without scrolling?
Hi.
Question
What's the best way to detect that text typed by user (or added programmatically) exceeds available container space and find out where starts truncated part? Is there available some other (than described bellow) easy way to detect it or disallow set of controllers to receive more characters that can be displayed in given composition area?
My partialy failed attempt (simplified)
For example lets say that I've got an editable textflow with attached two instances of ContainerController.
var flow:TextFlow = createSomeFlowFromGivenString(sampleText),
firstController = new ContainerController(firstSprite, 100, 30),
lastController = new ContainerController(secondSprite, 600, 30);
flow.interactionManager = new EditManager(new UndoManager());
flow.flowComposer.addController(firstController);
flow.flowComposer.addController(lastController);
flow.flowComposer.updateAllControllers();
With enabled vertical scroll policy I can compare height of the composition in last controller with height of the content:
var bounds:Rectangle = lastController.getContentBounds(),
overflow:Boolean = lastController.compositionHeight < bounds.height;
trace('Content does not fit into given area?', overflow)
But when I switch vertical scroll policy off (lastController.verticalScrollPolicy = ScrollPolicy.OFF) - unfortunately this no longer works...(In my case scrolling should be dissabled, since text areas might have only one line with restricted width)
Use case
I want to create fillable form. Field might have a single or multiple lines. One field might start in the middle of the page, continue in the next line where it spreads through whole page and end in the - quarter of page width long - third line. Text typed by the user can't exceed given area since it might cover some static text that sits right after/below field.
Something like ascii image bellow:
-------------------------------------------- | <PAGE> | | | | | | | | [Field starts here........ | | ........................................ | | ........................................ | | Ends here..] | | | | | | [Another field] xxxx xxxx xxxxxxxx x xx | | xxxxxxxxxxxxxxxxxxx | | | | [One more.. | | .....] | | | | | | | | | | | | | | | | | --------------------------------------------
Info:
[......] <-- form fields starts with '[' character, and ends with ']' xxx <-- sample, static text | and _ <-- page borders
