2016-09-19 77 views
1

我想在Spark TextArea中輸入選項卡,我發現的唯一示例是針對mx TextArea。如何在Spark Textarea中允許選項卡?

下面是我從建議使用使用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

這應該得到你想要的結果:

<?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> 

這適用於Flex 4.6.0

+0

這似乎是隻讀屬性。 –

+0

我已經嘗試了下面的方法沒有效果:'\t var config:Configuration = new Configuration(); \t var parser:ITextImporter; \t \t config.manageTabKey = true; \t parser = TextConverter.getImporter(TextConverter.PLAIN_TEXT_FORMAT,config); \t \t textarea.textFlow = parser.importToFlow(「test」);' –

+0

您使用的是什麼彈性版本?我已經在4.6.0中測試過它,它的功能就像一個魅力。 –

相關問題