Flex 组合框隐藏和显示向下箭头

发布于 2024-08-27 02:33:25 字数 1435 浏览 4 评论 0原文

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

尴尬癌患者 2024-09-03 02:33:25

我找到了一个简单的方法来做到这一点:

setStyle("arrowButtonWidth", 0);

在我的自定义组合框中,我将箭头按钮的初始宽度设置为0。

然后在List更改事件中,

  addEventListener(ListEvent.CHANGE, changeHandler);

如果dataprovider的大小大于1,则将箭头宽度设置回(比如说)20

  setStyle("arrowButtonWidth", 20);

这种方法很多比上述方法更简单。如果您知道我的方法有任何陷阱,请分享。

I found out an easy way to do this:

setStyle("arrowButtonWidth", 0);

In my custom combobox, I set the initial width of the arrow button to 0.

Then in the List change event,

  addEventListener(ListEvent.CHANGE, changeHandler);

if the size of the dataprovider is greater than 1, the arrow width is set back to (say) 20

  setStyle("arrowButtonWidth", 20);

This approach is much simpler than the above approaches. If you know any pitfall of my approach, please share.

在风中等你 2024-09-03 02:33:25

如何使用具有两种状态的两个组件(文本输入和组合)创建一个简单的自定义画布。
您在一种状态下显示文本输入,在另一种状态下显示组合?

<?xml version="1.0" encoding="utf-8"?>
<mx:Canvas xmlns:mx="http://www.adobe.com/2006/mxml" width="400" height="300">
    <mx:states>
        <mx:State name="combo">
            <mx:RemoveChild target="{textinput1}"/>
            <mx:AddChild position="lastChild">
                <mx:ComboBox x="48" y="10"></mx:ComboBox>
            </mx:AddChild>
        </mx:State>
    </mx:states>
    <mx:TextInput x="48" y="10" id="textinput1"/>
    <mx:Label x="10" y="12" text="Text"/>

</mx:Canvas>

How about creating a simple custom canvas with both components (textinput and combo) with two states.
You display the textinput in one state and the combo in the other state?

<?xml version="1.0" encoding="utf-8"?>
<mx:Canvas xmlns:mx="http://www.adobe.com/2006/mxml" width="400" height="300">
    <mx:states>
        <mx:State name="combo">
            <mx:RemoveChild target="{textinput1}"/>
            <mx:AddChild position="lastChild">
                <mx:ComboBox x="48" y="10"></mx:ComboBox>
            </mx:AddChild>
        </mx:State>
    </mx:states>
    <mx:TextInput x="48" y="10" id="textinput1"/>
    <mx:Label x="10" y="12" text="Text"/>

</mx:Canvas>
七婞 2024-09-03 02:33:25

您还可以为这两种情况提供自定义按钮外观,可以通过更改 styleName 来访问该外观。这可能比 user294702 的解决方案更轻。

例如,对源和符号使用虚拟名称:

.comboBoxWithArrow {
  up-skin: Embed(source="graphics.swf",symbol="comboArrowUp");
  down-skin: Embed(source="graphics.swf",symbol="comboArrowDown");
  over-skin: Embed(source="graphics.swf",symbol="comboArrowOver");
  disabled-skin: Embed(source="graphics.swf",symbol="comboArrowDisabled");
  /* and any other skin states you want to support */
}

.comboBoxWithoutArrow {
  up-skin: Embed(source="graphics.swf",symbol="comboNoArrowUp");
  down-skin: Embed(source="graphics.swf",symbol="comboNoArrowDown");
  over-skin: Embed(source="graphics.swf",symbol="comboNoArrowOver");
  disabled-skin: Embed(source="graphics.swf",symbol="comboNoArrowDisabled");
  /* and any other skin states you want to support */
}

如果您的条件允许,请将 styleName 设置为显示箭头的名称,否则将其设置为不显示箭头的名称。

You could also provide a custom button skin for either case, which would be accessible by changing the styleName. This would potentially be lighter weight than user294702's solution.

For example, using dummy names for source and symbols:

.comboBoxWithArrow {
  up-skin: Embed(source="graphics.swf",symbol="comboArrowUp");
  down-skin: Embed(source="graphics.swf",symbol="comboArrowDown");
  over-skin: Embed(source="graphics.swf",symbol="comboArrowOver");
  disabled-skin: Embed(source="graphics.swf",symbol="comboArrowDisabled");
  /* and any other skin states you want to support */
}

.comboBoxWithoutArrow {
  up-skin: Embed(source="graphics.swf",symbol="comboNoArrowUp");
  down-skin: Embed(source="graphics.swf",symbol="comboNoArrowDown");
  over-skin: Embed(source="graphics.swf",symbol="comboNoArrowOver");
  disabled-skin: Embed(source="graphics.swf",symbol="comboNoArrowDisabled");
  /* and any other skin states you want to support */
}

If your conditions warrant it, set the styleName to the one that shows the arrow, otherwise set it to the one that shows no arrow.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文