flex tree自动显示横向滚动条实现代码
程序员文章站
2022-03-07 18:38:37
复制代码 代码如下: package com.anydata.consumer.components { import flash.events.event; import...
复制代码 代码如下:
package com.anydata.consumer.components
{
import flash.events.event;
import mx.controls.tree;
import mx.core.scrollpolicy;
import mx.core.mx_internal;
/**
* 自动显示横向滚动条
*/
public class autosizetree extends tree
{
public function autosizetree()
{
super();
horizontalscrollpolicy=scrollpolicy.auto;
}
override public function get maxhorizontalscrollposition():number
{
if (isnan(mx_internal::_maxhorizontalscrollposition))
return 0;
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);
var indentation:number=getstyle("indentation");
if (diffwidth <= 0)
maxhorizontalscrollposition=nan;
else
maxhorizontalscrollposition=diffwidth + indentation;
super.updatedisplaylist(unscaledwidth, unscaledheight);
}
}
}
上一篇: Flex自定义右键菜单具体实现