我有一个附加了SelectionManager的TextFlow。我想得到光标在其中的FlowElement,或者如果选择了多行,则选择在其中。
_textFlow.addEventListener(SelectionEvent.SELECTION_CHANGE,selectionChangeListener,false,0,true);
private function selectionChangeListener(e:SelectionEvent):void
{
var selectionState:SelectionState = e.selectionState;
var selectedElementRange:ElementRange = ElementRange.createElementRange(selectionState.textFlow, selectionState.absoluteStart, selectionState.absoluteEnd);
}
答案 0 :(得分:0)
我找到了如何使用以下方法找到叶元素,但仍然不知道如何找到包含选择的元素 。
/** Returns the current FlowELement element at the currentStyleLevel */
private function currentStyleElement(absolutePosition:int):FlowElement
{
var e:FlowElement;
switch(currentStyleLevel)
{
case TextFlow:
e = _textFlow;
break;
case ParagraphElement:
e = _textFlow.findLeaf(absolutePosition).getParagraph();
break;
default:
e = _textFlow.findLeaf(absolutePosition);
}
return e;
}