当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
值。更多细节在这里。     

要回复问题请先登录注册