我有一個坐在分隔框中的樹組件。如果分割框被調整大小,我想在節點標籤上顯示'...'。我有一個自定義的itemrenderer,並且一直在尋找labelFunction屬性以及在自定義的itemrenderer中嘗試各種方法。沒有任何喜悅。 任何指針,將不勝感激。樹中的標籤上設置truncateToFit
繼承人一些示例代碼FO我如何設置它...
我定義了一個樹...
<mx:Tree
id="tree"
dataProvider="myData"
labelFunction="treeNodeLabel"
width="100%" height="100%"
click="handleClick(event)"
mouseMove="handleMouseMove(event)"
itemRollOver="handleItemOver(event)"
itemRollOut="handleItemOut(event)"
doubleClickEnabled="true"
doubleClick="handleDoubleClick(event)"
iconFunction="customIcon"
dragEnabled="true"
dropEnabled="true"
dragMoveEnabled="true"
dragOver="onDragOver(event)"
dragStart="onDragStart(event)"
dataDescriptor="{new DiagramTreeDataDescriptor()}"
itemRenderer="myCustomeRenderer"
borderStyle="none"
>
的自定義呈現是延伸檢測TreeItemRenderer的ActionScript類。 ..
public class myCustomRenderer extends TreeItemRenderer {
public function myCustomRenderer() {
super();
}
/**
* Create child objects of the component.
*/
override protected function createChildren():void {
super.createChildren();
createIcon();
addListeners();
addChild(Icon1);
addChild(Icon2);
}
private function createIcon() : void {
...
}
private function addListeners() : void {
...
}
private function Icon1Click(event: MouseEvent):void {
...
}
private function Icon2Click(event: MouseEvent): void {
...
}
private function onLabelMouseOver(event : MouseEvent):void {
...
}
private function onLabelMouseOut(event : MouseEvent):void {
...
}
private function getDescription(node : XML):String {
...
}
override protected function updateDisplayList(...) {
...
}
override public function set listData(value:BaseListData):void {
...
}
}
你在渲染器中使用s:Label嗎? – Exort
嗨,我是相當新的靈活,所以如果我有點含糊道歉!答案是否定的(我想!)。雖然我有一個cutom渲染器,但它用於控制其他內容,例如單擊也顯示在每個節點上的圖標。我想我使用的是默認的顯示方式。例如,我在我的自定義渲染器中引用了super.label,並且它「apprears」是一個TextField(它不支持截斷)。對不起,如果這是模糊 – fatlog
也許你可以發佈一些代碼,使事情更清晰 – Exort