如何解决当popUpWidthMatchesAnchorWidth为FALSE时,将下拉列表向右对齐
| 我已经为DropDownList创建了一个自定义皮肤(即修改了默认的“ 0”),并为其按钮创建了“ 1”。 除了获取下拉列表以与按钮右侧对齐的列表之外,我已经能够执行几乎所有我想做的事情。在按钮子皮肤中设置ѭ2allows可以根据项目的宽度来确定列表,因为显然按钮/整个控件的宽度远远小于要求的宽度。 这是现在的样子(默认popUpPosition = \“ bottom \”) 设置popUpPosition = \“ right \” 这是我想要的样子 因此,在这一点上,我要么需要深入研究DropDownList的所有spark源代码,以更好地了解其工作原理,要么这里的某人已经知道如何执行此操作。 任何想法,将不胜感激。解决方法
您可以创建一个自
PopUpAnchor
扩展的自定义PopUpAnchor
类,并覆盖其definePosition函数来修改PopUpPosition.BELOW
的行为:
override mx_internal function determinePosition(placement:String,popUpWidth:Number,popUpHeight:Number,matrix:Matrix,registrationPoint:Point,bounds:Rectangle):void
{
switch(placement)
{
case PopUpPosition.BELOW:
registrationPoint.x = -popUpWidth + unscaledWidth;
registrationPoint.y = unscaledHeight;
break;
case PopUpPosition.ABOVE:
registrationPoint.x = 0;
registrationPoint.y = -popUpHeight;
break;
case PopUpPosition.LEFT:
registrationPoint.x = -popUpWidth;
registrationPoint.y = 0;
break;
case PopUpPosition.RIGHT:
registrationPoint.x = unscaledWidth;
registrationPoint.y = 0;
break;
case PopUpPosition.CENTER:
registrationPoint.x = (unscaledWidth - popUpWidth) / 2;
registrationPoint.y = (unscaledHeight - popUpHeight) / 2;
break;
case PopUpPosition.TOP_LEFT:
// already 0,0
break;
}
}
设置registrationPoint.x = -popUpWidth + unscaledWidth
使其与按钮的右边缘对齐。
在DropDownList
皮肤中,将PopUpAnchor
标记替换为新创建的类,并且您应有一个DropDownList
,其行为符合您的要求。
也许有一个更明智的方法,但是我宁愿花时间不知道那是什么。
, PopUpAnchor具有一个名为layoutDirection的属性。我相信这就是您要寻找的。
如果将该属性设置为\“ rtl \”,则下拉列表将根据需要对齐。
, 除了调整popUpWidthMatchesAnchorWidth
之外,还尝试调整皮肤PopUpAnchor
中的11ѭ。它可以接受left
和right
值。更多细节在这里。
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。