是否有可用于选择FlowElement的方法?我检查了一些类,包括SelectionManager和EditManager,但是没有看到任何东西。
发布于 2015-02-17 10:35:30
下面的示例演示如何选择元素:
<fx:Script>
<![CDATA[
import flashx.textLayout.edit.ISelectionManager;
import flashx.textLayout.edit.SelectionState;
import flashx.textLayout.elements.FlowElement;
import flashx.textLayout.elements.TextFlow;
protected function selectElementHandler(event:MouseEvent):void {
var selectionManager:ISelectionManager = activeFlow.interactionManager as ISelectionManager;
var element:FlowElement = activeFlow.findLeaf(selectionManager.anchorPosition);
selectElement(element);
}
public function selectElement(flowElement:FlowElement):void {
var textFlow:TextFlow = flowElement.getTextFlow();
var selection:SelectionState = ISelectionManager(textFlow.interactionManager).getSelectionState();
var startIndex:int = flowElement.getAbsoluteStart();
selection.updateRange(startIndex, startIndex + flowElement.textLength);
IEditManager(textFlow.interactionManager).setSelectionState(selection);
textFlow.flowComposer.updateAllControllers();
}
]]>
</fx:Script>
<s:Button label="Select current element" click="selectElementHandler(event)"/>https://stackoverflow.com/questions/28537356
复制相似问题