Flex's text-editing controls (mx:TextField, mx:TextArea) offer functions for doing "stuff" with the selected text (selectionBeginIndex
, selectionEndIndex
, setSelection
), but the text-displaying controls (mx:Label, mx:Text) don't seem to offer anything of the sort.
After some tinkering, I've tried subclassing Label then writing functions which give access to the underlying TextField
instance... But even then, setting the selection didn't work!
function get selectionBeginIndex():int {
// This works
return this.textField.selectionBeginIndex;
}
function get selectionEndIndex():int {
// This works
return this.textField.selectionEndIndex;
}
function setSelection(beginIndex:int, endIndex:int):void {
// But this has no effect!
this.textField.setSelection(beginIndex, endIndex);
}
So, is there any better way to access/change the text which is selected in mx:Label and mx:Text controls? Are there "better" controls to use?