有没有一种我可以用来选择FlowElement的方法?我检查了几个类,包括SelectionManager和EditManager,但没有看到任何内容。
以下示例显示了如何选择元素:
<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)"/>
本文收集自互联网,转载请注明来源。
如有侵权,请联系 [email protected] 删除。
我来说两句