2011-05-05 124 views
0

我试图从粘贴到Spark TextArea的文本中删除所有换行符。从Spark TextArea中的粘贴文本中删除换行符

我: <s:TextArea id="inputSearchQuery" width="100%" height="22" minHeight="22" maxHeight="196" changing="onInputSearchQueryChanging(event)"/>

和Handler:

private function onInputSearchQueryChanging(evt:TextOperationEvent = null):void { 
    if (evt.operation is PasteOperation) { 

    } 
} 

在哪里可以找到该用户粘贴文本?据我所知,这个文本应该在evt.operation.textFlow中,但它不是......我很困惑。

回答

0

粘贴文本在(evt.operation as PasteOperation).textScrap。所以你可以从textScrap.textFlow中提取文本。

+0

嗯...使用tlf_internal命名空间?这不是黑客?没有更简单的方法吗? – 2011-05-05 11:31:27

+0

这个命名空间不是黑客。这只是为了高级用途。你可以使用它没有任何问题。 – Constantiner 2011-05-05 11:33:34

+0

Thnx!所以,为了消除换行符,我需要交替(evt.operation作为PasteOperation).textScrap.textFlow并且不防止evt?我试着这样做:'var tf:TextFlow \t \t \t =(evt.operation as PasteOperation).textScrap.textFlow; \t \t \t \t \t var p:ParagraphElement \t = new ParagraphElement(); \t \t \t \t \t var span:SpanElement \t = new SpanElement(); \t \t \t \t \t VAR吨:字符串\t \t \t = tf.getText(); \t \t \t \t \t \t span.text \t \t \t = t.replace(/ \ N/IG, “”); \t \t \t \t \t p.addChild(span); \t \t \t \t \t tf.replaceChildren(0,tf.numChildren,p);'但是得到异常( – 2011-05-05 11:42:16