getting the format of unselected text range in TextFlow
Hello,
I am trying to mimic the functionality of TextField's "getTextFormat()/setTextFormat()" in a class using TLF. These methods allow you to specify a beginIndex/endIndex and let you get all common styles to the specified range, or for the whole TextField if no range is specified. I have found that the SelectionManager/EditManager will allow you to get/set common formats, which I could then use to create a TextFormat class with the appropriate values. However, these methods only apply to a currently-selected range of text, rather than a programmatically-specified one. Is there any way to do what I'm attempting without, in the example of "getTextFormat()":
1) caching a current selection
2) caching the focusSelectionFormat/inactiveSelectionFormat
3) changing the focusSelectionFormat/noFocusSelectionFormat properties to mimic the current inactiveSelectionFormat (so it doesn't look like I'm selecting them)
4) doing a setSelection() on the specified range
5) calling getCommonContainerFormat(), getCommonParagraphFormat(), getCommonCharacterFormat() to get the common values
6) creating a TextFormat that uses the values returned from the previous step
7) resetting to cached formats
😎 resetting to cached selection
This seems like a very difficult, as well as heavy, way to get the styles on a specified range, but I have been unable to find any functionality that does what SelectionManager::getCommonContainerFormat(), SelectionManager::getCommonParagraphFormat(), SelectionManager::getCommonCharacterFormat() and EditManager::applyFormat() does without relying on the current selection. If anyone knows of something that allows me to do this, or just a better way of doing this than the above-described flow, I would greatly appreciate any suggestions or comments.
Thanks,
Christian Pillsbury
Digital Primates
