-
1. Re: getCharBoundaries equivalent in spark text components
Peter deHaan Jul 21, 2009 2:48 PM (in response to dave cragg)Dave,
Sorry, I haven't tried this yet myself, but is this post helpful? http://forums.adobe.com/thread/453085
Feel free to file an enhancement request at http://bugs.adobe.com/flex/ if you think this is a common use case and should be made easier.
Peter
-
2. Re: getCharBoundaries equivalent in spark text components
dave cragg Jul 22, 2009 8:10 AM (in response to Peter deHaan)Thanks Peter. The link was very helpful.
I wasn't able to work directly from a RichText or RichEditableText component. I couldn't see how to get the flowComposer of the textFlow associated with either component. But I managed to construct a custom text layout component, and the procedure in the linked article worked as described. The y coordinate returned from getAtomBounds was a bit confusing. It was always a negative number. However, I could use the bounds rectangle of the textLine itself to get the y coordinate I needed.
-
3. Re: getCharBoundaries equivalent in spark text components
Peter deHaan Jul 22, 2009 11:41 AM (in response to dave cragg)dave,
How about: richEdTxt.textFlow.flowComposer ?
Peter
-
4. Re: getCharBoundaries equivalent in spark text components
dave cragg Jul 22, 2009 1:58 PM (in response to Peter deHaan)Sorry, Peter. I wasn't very clear when I said I couldn't get the flowComposer. I tried what you suggested, but it returned null. Same for RichText.
-
5. Re: getCharBoundaries equivalent in spark text components
Peter deHaan Jul 22, 2009 2:06 PM (in response to dave cragg)dave,
Good catch! Can you please file a bug at http://bugs.adobe.com/flex/ and include a simple test case (actually, I was able to repro with the test case below if you want to use that code)? (and then post the bug number here so I can subscribe and assign to the correct person).
You can see from the code below that the flowComposer seems to be null by default, but if you edit the code you will get a flowComposer object back.
<?xml version="1.0" encoding="utf-8"?> <s:Application xmlns:fx="http://ns.adobe.com/mxml/2009" xmlns:s="library://ns.adobe.com/flex/spark" xmlns:mx="library://ns.adobe.com/flex/halo"> <s:layout> <s:VerticalLayout paddingLeft="20" paddingTop="20" /> </s:layout> <fx:Script> <![CDATA[ import mx.utils.ObjectUtil; private function init():void { debug.text = ObjectUtil.toString(richEdTxt.textFlow.flowComposer); btn.enabled = false; } ]]> </fx:Script> <s:RichEditableText id="richEdTxt" change="btn.enabled = true;"> <s:textFlow> <s:TextFlow> <s:p>The quick brown <s:span fontWeight="bold">fox jumps over</s:span> the lazy dog</s:p> </s:TextFlow> </s:textFlow> </s:RichEditableText> <s:Button id="btn" label="get flowComposer" click="init();" /> <s:TextArea id="debug" width="550" height="300" /> </s:Application>
Thanks,
Peter
-
6. Re: getCharBoundaries equivalent in spark text components
dave cragg Jul 22, 2009 4:57 PM (in response to Peter deHaan)Peter, I filed a report - SDK-22374
Interestingly, I wasn't able to get your example to run. It stalled on startup (in debug mode) with the progress bar about half-way finished. I had to set the textFlow of the RET on creationComplete. I'm guessing your using a later SDK build than me. (I'm using 4.0.0.8469) So this may not be an issue any more. This was with Safari 4.0.2 (OS X).