flex tree gets chopped even after using scroll bar

最后都变了- 提交于 2019-12-14 00:40:27

问题


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.

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. 

)

Kindly help me .Thanks a lot in advance.


回答1:


Looking at your picture, I'd suspect the issue has nothing to do with the specific tree, and is only slightly related to the renderer. Instead, I think that when the container holding the Tree is created, it doesn't have a size, and when the Tree sizes its renderers, it gives them the wrong size. Since List-based controls don't set the actual width on renderers, choosing to set explicitWidth instead, the renderers aren't triggered into changing their size.

Check out http://www.developria.com/2009/12/handling-delayed-instantiation-1.html for more explicit details and fixes.




回答2:


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


来源:https://stackoverflow.com/questions/7088097/flex-tree-gets-chopped-even-after-using-scroll-bar

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!