Skip to main content
Inspiring
February 18, 2009
Answered

Multiple containers for same TextFlow

  • February 18, 2009
  • 2 replies
  • 544 views
I have a pretty complex scenario but I should be able to see what's going wrong here... the question is on the very last line.

I'm building an application where inside an editor users can lay out and edit text, (using things like resize handles and the EditManager for position and selection/typing). The app has a strict MVC implementation and I'm utilising a global undo system via commands so every edit to the text runs through a central mechanism instead of using the UndoManager directly. I'm also generating thumbnail images of this "container" after a certain time period after user activity, in effect producing 2 views of the same data.

The problem this causes is that each TextFlow object is now being used by two Containers (I'm using a "TextElementRenderer" as a container class, which takes a TextFlow object and using the TLF draws the text). So it only actually renders in the last one assigned (in my case the thumbnail which lives inside a TileList that lets you switch between editors).

So to avoid this I could just perform a clone/deep copy of the TextFlow, but due to aforementioned approach I need a single TextFlow to exist so that one change update's all, and I'm also editing this via a properties panel (bold/italic etc), which lives elsewhere in the visual hierarchy (I have quite a few types of element apart from text that can be placed on stage and many property panels in this system to cater for them).

So is there a way to allow 2 containers to be used for one TextFlow?
This topic has been closed for replies.
Correct answer richardleggettmk
Thanks for your response, I'm glad I'm not just missing something. I have ended up with a fairly clean solution in that only 1 container needs to be actively editing the model at any one time (depending on focus), so if I have 2 containers both using the model the one that is not actively editing (the thumbnail in this case) can re-create clones whenever the active container updates the text as it is merely displaying the TextFlows and not actually allowing direct user editing via an EditManager/mouse/keyboard.

It's not as efficient as detecting changes to a single TextFlow instance but it works fast enough for most scenarios.

The properties panel is not really affected as it can still grab a reference to the TextFlow's EditManager and work on it from there.

Speaking of which, I think also the docs could promote better the Selection(/Edit)Manager.getCommonCharacterFormat() method as it took a while to find this and it's needed as soon as you start to implement things like Bold/Italic/etc buttons (where the TextFlow's container loses focus) and the pointFormat is nullified as soon as you click the button (due to the focus change/loss of carat).

2 replies

richardleggettmkAuthorCorrect answer
Inspiring
February 18, 2009
Thanks for your response, I'm glad I'm not just missing something. I have ended up with a fairly clean solution in that only 1 container needs to be actively editing the model at any one time (depending on focus), so if I have 2 containers both using the model the one that is not actively editing (the thumbnail in this case) can re-create clones whenever the active container updates the text as it is merely displaying the TextFlows and not actually allowing direct user editing via an EditManager/mouse/keyboard.

It's not as efficient as detecting changes to a single TextFlow instance but it works fast enough for most scenarios.

The properties panel is not really affected as it can still grab a reference to the TextFlow's EditManager and work on it from there.

Speaking of which, I think also the docs could promote better the Selection(/Edit)Manager.getCommonCharacterFormat() method as it took a while to find this and it's needed as soon as you start to implement things like Bold/Italic/etc buttons (where the TextFlow's container loses focus) and the pointFormat is nullified as soon as you click the button (due to the focus change/loss of carat).
Adobe Employee
February 18, 2009
There is no easy way to do this. The model is polluted with the TextLines for the view.

Richard