即使使用滚动条,flex 树也会被砍断 [英] flex tree gets chopped even after using scroll bar

查看:23
本文介绍了即使使用滚动条,flex 树也会被砍断的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

当我使用以下树渲染器类时,树中的信息被切断.是否有任何解决方案可以修复此错误.请帮我.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.

在使用 google 冲浪时,我发现了修复此错误的建议,方法正确吗?(

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. 

)

请帮助我.非常感谢.

推荐答案

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

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

这篇关于即使使用滚动条,flex 树也会被砍断的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆