1

I would like to type in tabs in a Spark TextArea and the only examples I found are for mx TextArea.

Here is test data I'm using from the suggestion to use manageTabKey:

var config:Configuration = new Configuration();
var parser:ITextImporter;

config.manageTabKey = true;
parser = TextConverter.getImporter(TextConverter.PLAIN_TEXT_FORMAT, config);

textarea.textFlow = parser.importToFlow("test data");

MXML:

<s:TextArea id="textarea" width="100%" height="100%">

</s:TextArea>
1.21 gigawatts
  • 16,517
  • 32
  • 123
  • 231

1 Answers1

1

This should get you the wanted result:

<?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/mx" 
               minWidth="955" minHeight="600"
               creationComplete="creationCompleteHandler(event)">
    <fx:Script>
        <![CDATA[
            import mx.events.FlexEvent;

            import flashx.textLayout.elements.Configuration;

            protected function creationCompleteHandler(event:FlexEvent):void {
                (sparkTextArea.textFlow.configuration as Configuration).manageTabKey = true;
            }

        ]]>
    </fx:Script>
    <fx:Declarations>
        <!-- Place non-visual elements (e.g., services, value objects) here -->
    </fx:Declarations>
    <s:TextArea id="sparkTextArea" />
</s:Application>

This works in Flex 4.6.0

  • I've tried the following to no effect: ` var config:Configuration = new Configuration(); var parser:ITextImporter; config.manageTabKey = true; parser = TextConverter.getImporter(TextConverter.PLAIN_TEXT_FORMAT, config); textarea.textFlow = parser.importToFlow("test");` – 1.21 gigawatts Sep 27 '16 at 10:08
  • What flex version are you using? I have tested it in 4.6.0 and it works like a charm. – Robin van den Bogaard Sep 28 '16 at 07:45
  • I'll try again. I was sure that threw a compiler error as read only. Oh I think maybe because I cast it as IConfiguration??? – 1.21 gigawatts Sep 28 '16 at 22:00
  • That worked! Thanks. FYI I *was* casting it to `IConfiguration(sparkTextArea.textFlow.configuration as Configuration).manageTabKey = true;` and that was giving me the compiler error `Type 1059: Property is read-only.`. It works now. – 1.21 gigawatts Sep 28 '16 at 22:39