我已经为 DropDownList “创建”了一个自定义外观(即修改了默认的 spark.skins.spark.DropDownListSkin
)及其按钮的 spark.skins.spark.DropDownListButtonSkin
。
我已经能够让它做几乎所有我想做的事情,除了让下拉列表与按钮右侧对齐之外。在按钮子皮肤中设置
允许列表由项目的宽度确定,因为显然按钮/整个控件的宽度远远低于要求。
这是现在的样子(默认 popUpPosition="bottom")
设置 popUpPosition="right “
这是我想要的看起来像
所以在这一点上,我要么需要深入研究所有的 Spark 源代码让 DropDownList 更好地理解事情是如何工作的,或者也许这里有人已经知道如何做到这一点。
任何想法将不胜感激。
I have "created" a custom skin for DropDownList (i.e modified the default spark.skins.spark.DropDownListSkin
) and spark.skins.spark.DropDownListButtonSkin
for its button.
I have been able to get it to do almost everything I wanted, except for getting the list that drops down to align to the right of the button. Setting <s:PopUpAnchor popUpWidthMatchesAnchorWidth=*false* />
in the button sub-skin allows the list to be determined by the width of the items, because obviously the width of the button/entire control is far less than required.
Here is what it looks like now (default popUpPosition="bottom")
Setting popUpPosition="right"
Here is what I would like it to look like
So at this point, I either need to dig into all the spark source code for DropDownList to better understand how things work, or perhaps someone here knows how to do this already.
Any ideas would be appreciated.
发布评论
评论(3)
您可以创建一个从
PopUpAnchor
扩展的自定义PopUpAnchor
类,并重写其确定位置函数以修改PopUpPosition.BELOW
的行为方式:设置
RegistrationPoint.x = -popUpWidth + unscaledWidth
将其与按钮的右边缘对齐。在您的
DropDownList
皮肤中,将PopUpAnchor
标记替换为您新创建的类,您应该拥有一个按照您的请求运行的DropDownList
。也许有一种更明智的方法可以做到这一点,但我宁愿花时间不去弄清楚那是什么。
You can create a custom
PopUpAnchor
class which extends fromPopUpAnchor
, and override its determinePosition function to modify howPopUpPosition.BELOW
behaves:Setting
registrationPoint.x = -popUpWidth + unscaledWidth
aligns it with the right edge of the button.Within your
DropDownList
skin replace thePopUpAnchor
tag with your newly created class and you should have aDropDownList
which behaves as you requested.Perhaps there's a saner way of doing this, but I'd rather spend my time not finding out what that is.
PopUpAnchor 有一个名为layoutDirection 的属性。我相信这就是您所寻找的。
如果您将该属性设置为“rtl”,下拉列表将根据您的需要对齐。
PopUpAnchor has a property called layoutDirection. I believe that's what your looking for.
If you set that property to "rtl" the dropdown will be aligned as you want.
尝试调整
popUpPositionpopUpWidthMatchesAnchorWidth
之外,还可以在皮肤中添加PopUpAnchor
的代码>。它可以接受left
和right
值。更多详细信息请参见此处。Try to adjust
popUpPosition
ofPopUpAnchor
in your skin in addition to adjustingpopUpWidthMatchesAnchorWidth
. It can acceptleft
andright
values. More details is here.