单击下拉按钮的某些区域时,组合框立即关闭

Combobox is immediately closing when clicking on certain areas of dropdown button

我有一个 Spark ComboBox,它会在单击打开的下拉图标的某些区域时自动关闭弹出区域。我有一个 ComboBox 坐在这个弹出窗口旁边,效果很好。

首先弹出的是字体列表。第二个是字体大小列表。

当我用系统字体列表填充字体组合框时,我注意到它开始出现问题。数组中有 900 种字体。在此之前,字体列表中有 10 种字体。它适用于 10 种字体。

字体组合框在标注中,但这似乎无关紧要,因为第二个组合框工作正常。

我可以通过单击打开下拉按钮的中心来重现每次关闭的弹出区域。单击按钮中心的上方或下方可以正常工作。

如果我不得不猜测发生了什么,那就是项目的数量导致弹出窗口花费比平时更长的时间来定位,并且它暂时遮住了鼠标下方的区域并且鼠标事件是未被取消,因此弹出区域会立即关闭。我不知道,但我想不出其他任何办法,也想不出如何解决它。

示例应用程序:

<?xml version="1.0" encoding="utf-8"?>
<s:WindowedApplication xmlns:fx="http://ns.adobe.com/mxml/2009" 
                       xmlns:s="library://ns.adobe.com/flex/spark" 
                       xmlns:mx="library://ns.adobe.com/flex/mx"
                       applicationComplete="windowedapplication1_applicationCompleteHandler(event)">

    <fx:Style>
        @namespace s "library://ns.adobe.com/flex/spark";
        @namespace mx "library://ns.adobe.com/flex/mx";

        s|Scroller {
            skinClass: ClassReference("com.flexcapacitor.skins.MinimalScrollerSkin");
        }
    </fx:Style>
    <fx:Script>
        <![CDATA[
            import mx.collections.ArrayList;
            import mx.events.FlexEvent;

            protected function windowedapplication1_applicationCompleteHandler(event:FlexEvent):void
            {
                var fontList:Array = Font.enumerateFonts(true);
                fonts.dataProvider = new ArrayList(fontList);
                fontSizes.dataProvider = new ArrayList([1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16]);
                fonts.selectedIndex = fontList.length-1;
                fontSizes.selectedIndex = fontSizes.dataProvider.length-1;
            }

            public function fontLabelFunction(object:Object):String {
                if (object is Font) {
                    return Font(object).fontName;
                }
                return object as String;
            }
        ]]>
    </fx:Script>

    <s:HGroup verticalCenter="0" horizontalCenter="0">
        <s:ComboBox id="fonts" labelFunction="fontLabelFunction"/>
        <s:ComboBox id="fontSizes"/>
    </s:HGroup>

</s:WindowedApplication>

似乎是在使用 MinimalScrollerSkin 和大型数据集并准确单击下拉箭头区域时发生的。

看起来它是由 MinimalScrollerSkin 中的错误引起的。 MobileSkin class 上有一个 属性 叫做 useMinimumHitArea。 MinimalScrollerSkin 及其相关 classes 扩展了 MobileSkin。此 属性 默认设置为 true。

此 属性 的文档指出:

Toggles transparent, centered hit-area if the unscaled size is less than one-quarter inch square. Physical size is based on applicationDPI.

在皮肤中将此 属性 设置为 false 解决了这个问题。它还解决了轨道命中区域溢出到容器内容的问题。我必须创建一个 VScrollBarTrackSkin 来解决这个问题,因为设置 useMinimumHitArea 是绘制轨道的唯一方法。