I need to have a Text Area With Line Numbers, & once the Text File is Imported to the Text Area.. t开发者_开发问答he user must be able to select the line numbers & see the filtered output.
I have implemented the same with Numeric steppers. I am in search of an enhanced component.
are there better Advanced Components for Textarea ? Any Advanced Textarea component with built-in Search/Replace/Filter Capabilities ?
Cheers, Ajay
What do you consider to be a line? Do you need to take the line wrapping of the text area into consideration when you are selecting the lines, or are you only interested in the actual line characters in the underlying string?
If the latter applies, the you can probably accomplish what you want like this:
protected var selectedLineIndexes:Array = []; // of ints
// Find the lines which were selected.
textArea.text.split("\n").filter (
function (line:String, i:Index, a:Array):Boolean {
return selectedLineIndexes.indexOf(i) != -1;
}
)
If you are actually interested in the lines in the view, taking the width of the text area into account, then it will be more complicated. In this case, the TextLineMetrics class will probably come in handy. You can obtain a reference from the IUITextField which is a protected property of the TextArea. I.e. you need to subclass TextArea to get access to this information.
http://livedocs.adobe.com/flex/3/langref/flash/text/TextLineMetrics.html
http://livedocs.adobe.com/flex/3/langref/mx/core/IUITextField.html
精彩评论