0

I'm trying to remove all line breaks from the text that is pasted into the Spark TextArea.

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

And handler:

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

    }
}

Where can I find a text that user pasted? As I understand, this text should be in evt.operation.textFlow but it is not... I'm confused.

1 Answers1

0

Pasted text is in (evt.operation as PasteOperation).textScrap. So you can extract text from textScrap.textFlow.

Constantiner
  • 14,231
  • 4
  • 27
  • 34
  • Hmmm... Using tlf_internal namespace? This is not a hack? Is not there a simpler way? – Ilya Segeda aka ALFer May 05 '11 at 11:31
  • This namespace isn't hack. It is just for advanced use. You can use it without any problem. – Constantiner May 05 '11 at 11:33
  • Thnx! So, for removing line breaks I need to alternate (evt.operation as PasteOperation).textScrap.textFlow and do not preventing evt? I'm trying this: `var tf:TextFlow = (evt.operation as PasteOperation).textScrap.textFlow; var p:ParagraphElement = new ParagraphElement(); var span:SpanElement = new SpanElement(); var t:String = tf.getText(); span.text = t.replace(/\n/ig, ""); p.addChild(span); tf.replaceChildren(0, tf.numChildren, p);` But get exception ( – Ilya Segeda aka ALFer May 05 '11 at 11:42