弯曲的树被即使使用滚动条后切碎弯曲、滚动条

2023-09-08 12:44:10 作者:大漠孤鹰

当我用下面的树渲染器类在树中的informtions被砍伤。有没有什么解决方案来解决这个问题。请帮助我。 所述PLTree类如下:

when i use the following tree renderer class the the informtions in the tree gets chopped. Is there any solution to fix this bug. please help me. The PLTree class is as follows:

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();
        }
    }   
}

我附上了它的外观执行时的图像文件。

i am attaching the image file of how it looks when executed.

在使用谷歌冲浪,我发现一个suggesion来修复这个bug是它的正确方法? (

When surfing using google i found a suggesion to fix this bug is it the right way ? (

Issue: Text getting chopped of at end.
Fix: change
maxHorizontalScrollPosition = diffWidth;
to
maxHorizontalScrollPosition = diffWidth + 10;
or what ever correction factor you need. 

请帮我.Thanks很多提前。

Kindly help me .Thanks a lot in advance.

推荐答案

类似于上述程序的滚动处理。使用鼠标滚轮的滚动处理程序来处理该事件,如下所示:

similar to the scroll handler in the above mentioned program. Use a mouse wheel scroll handler to handle that event as follows:

override protected function mouseWheelHandler(eventMouse:MouseEvent):void
     {      if (mx_internal::isOpening)
            return;

        if (eventMouse is MouseEvent){          
            super.mouseWheelHandler(eventMouse);
            invalidateDisplayList();
        }
     }