当我使用下面的树渲染器类时,树中的信息被切断。有没有解决方案来修复这个bug。请帮我。 PLTree类如下:
import flash.events.Event;
import mx.events.ScrollEvent;
import mx.controls.Tree;
import mx.core.ScrollPolicy;
import mx.core.mx_internal;
import mx.events.TreeEvent;
public class PLTree extends Tree
{
private var _lastWidth:Number = 0;
private var _lastHeight:Number = 0;
public function PLTree() {
super();
horizontalScrollPolicy = ScrollPolicy.AUTO;
}
override public function get maxHorizontalScrollPosition():Number
{
return mx_internal::_maxHorizontalScrollPosition;
}
override public function set maxHorizontalScrollPosition(value:Number):void
{
mx_internal::_maxHorizontalScrollPosition = value;
dispatchEvent(new Event("maxHorizontalScrollPositionChanged"));
scrollAreaChanged = true;
invalidateDisplayList();
}
override protected function updateDisplayList(unscaledWidth:Number, unscaledHeight:Number):void
{
var diffWidth:Number = measureWidthOfItems(0,0) - (unscaledWidth - viewMetrics.left - viewMetrics.right);
if (diffWidth <= 0) {
maxHorizontalScrollPosition = 0;
horizontalScrollPolicy = ScrollPolicy.OFF;
} else {
maxHorizontalScrollPosition = diffWidth;
horizontalScrollPolicy = ScrollPolicy.ON;
}
super.updateDisplayList(unscaledWidth, unscaledHeight);
}
override protected function scrollHandler(event:Event):void
{
if (mx_internal::isOpening)
return;
// TextField.scroll bubbles so you might see it here
if (event is ScrollEvent){
super.scrollHandler(event);
invalidateDisplayList();
}
}
}
我正在附加执行时的外观图像文件。
使用谷歌浏览我发现修复此错误的建议是正确的方法吗? (
Issue: Text getting chopped of at end.
Fix: change
maxHorizontalScrollPosition = diffWidth;
to
maxHorizontalScrollPosition = diffWidth + 10;
or what ever correction factor you need.
)
请帮帮我。谢谢你。
答案 0 :(得分:0)
查看您的图片,我怀疑该问题与特定树无关,并且只与渲染器有点关联。相反,我认为当创建持有Tree的容器时,它没有大小,并且当Tree调整其渲染器大小时,它会给它们错误的大小。由于基于列表的控件不在渲染器上设置实际宽度,因此选择设置explicitWidth,不会触发渲染器更改其大小。
查看http://www.developria.com/2009/12/handling-delayed-instantiation-1.html以获取更多详细信息和修正。
答案 1 :(得分:0)
类似于上述程序中的滚动处理程序。使用鼠标滚轮滚动处理程序来处理该事件,如下所示:
override protected function mouseWheelHandler(eventMouse:MouseEvent):void
{ if (mx_internal::isOpening)
return;
if (eventMouse is MouseEvent){
super.mouseWheelHandler(eventMouse);
invalidateDisplayList();
}
}