我的 Flex 4.6 Web 应用程序的少数用户抱怨说,它右下角的 mx.controls.PopUpButton 有时会在它下面打开一个列表,因此无法使用(我自己无法重现——可能是他们的不幸组合Flash 播放器和/或字体大小设置?)
我如何确保 popUp 组件(在我的情况下是 spark.components.List)始终在 PopUpButton上方打开?
我怀疑,我应该基于 mx.skins.halo.PopUpButtonSkin 创建一个皮肤并将其分配给我的 PopUpButton?我可能应该将 PopUpPosition.ABOVE 常量与 PopUpAnchor 一起使用?
但我不知道如何把它放在一起 - 任何人都可以分享一些说明吗?
我准备了一个截图和一个简单的Text.mxml:
<?xml version="1.0" encoding="utf-8"?>
<s:Application
xmlns:fx="http://ns.adobe.com/mxml/2009"
xmlns:s="library://ns.adobe.com/flex/spark"
xmlns:mx="library://ns.adobe.com/flex/mx"
creationComplete="init()">
<fx:Script>
<![CDATA[
import mx.events.FlexEvent;
import mx.collections.ArrayCollection;
import spark.components.List;
[Bindable]
private var _data:ArrayCollection = new ArrayCollection();
[Bindable]
private var _list:List = new List();
public function init():void {
_data.addItem({label: "One"});
_data.addItem({label: "Tow"});
_data.addItem({label: "Three"});
_data.addItem({label: "Four"});
_data.addItem({label: "Five"});
_list.dataProvider = _data;
_list.setStyle('fontSize', 36);
}
]]>
</fx:Script>
<mx:PopUpButton right="10" bottom="10" fontSize="24" popUp="{_list}"/>
</s:Application>
更新:
我找到了 Simon Bailey MX ComboBox Open Direction Bug - Alternative Solution的解决方案,它有点工作,但不幸的是,当单击主(不是箭头)按钮时,我无法调度我的自定义事件。
我还查看了 PopUpButton.as 源代码,想知道 List 的高度是否为 0,而在那里检查它:
private function displayPopUp(show:Boolean):void
{
......
// XXX I suspect the _popUp.height below is 0
// XXX for the users having the trouble
if (show)
{
if (point.y + _popUp.height > screen.bottom &&
point.y > (screen.top + height + _popUp.height))
{
// PopUp will go below the bottom of the stage
// and be clipped. Instead, have it grow up.
point.y -= (unscaledHeight + _popUp.height + 2*popUpGap);
initY = -_popUp.height;
}
我自己仍然无法重现该错误,我的用户不是很有帮助(主要是老年人,玩我的纸牌游戏)。我在 Adobe JIRA中搜索过,但找不到这样的错误。
我想知道,是否有办法使该方法短路以强制打开 PopUpButton 上方的 popUp。
或者,如果我应该将 _list 放入某个容器中......