, textpane.text
에서 substring
전화 :
var start:int = textpane.selectionBeginIndex;
var end:int = textpane.selectionEndIndex;
var text:String = textpane.text.substring(start, end);
TextField
및 TLFTextField
텍스트를 삽입 할 수 있습니다 replaceText()
기능을 구현한다. ,
textpane.replaceText(end, end, "<--");
둘 모두에서 시작 삽입하고 종료 인덱스하려면이의 길이를 보상 보장 :
textpane.replaceText(start, start, "-->");
가 최종 인덱스에 교체하려면 :
은 시작 인덱스 교체하려면 삽입 된 텍스트.
end += insertedText.length;
은 모두 함께,이된다 :
// find start and end positions
var start:int = textpane.selectionBeginIndex;
var end:int = textpane.selectionEndIndex;
// selected text
var text:String = textpane.text.substring(start, end);
// insert text at beginning of selection
var inseredtText:String = "-->";
textpane.replaceText(start, start, insertText);
// insert text at end of selection
end += insertedText.length;
textpane.replaceText(end, end, "<--");
감사합니다! 그것은 힙을 도왔다. – user1522256