Flex - 有没有办法指定 ComboBox 将打开的方向? [英] Flex - Is there a way to specify what direction a ComboBox will open?

查看:20
本文介绍了Flex - 有没有办法指定 ComboBox 将打开的方向?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

也许我应该进一步限定这一点 - 有没有一种方法可以指定 ComboBox 将打开的方向,而无需复制和粘贴整个 ComboBox 类并撕掉它确定它将在哪个方向打开的代码...

Maybe I should further qualify this - Is there a way to specify which direction a ComboBox will open without copying and pasting the entire ComboBox class and ripping out the code where it determines which direction it will open in...

我是我的特殊情况 - 我需要它向上打开 - 总是.

I'm my specific case - I need it to open upwards - always.

更新:你不能通过继承它来解决这个问题,因为处理开口方向的函数是:

UPDATE: You can't fix this by subclassing it because the function that handles the direction of the opening is:

private function displayDropdown(show:Boolean, trigger:Event = null):void

那个坏男孩使用了大量我的子类无法访问的私有变量......

And that bad boy uses a fair amount of private variables which my subclass wouldn't have access to...

推荐答案

如果您自己构建 Menu 对象,则只需设置菜单对象的 x,y 坐标,就可以将菜单放置在您想要的任何位置.您需要计算这些坐标,但您可能无需继承 ComboBox 就可以轻松完成此操作.

If you build up the Menu object yourself, you can place the menu anywhere you want by simply setting the x,y coordinates of the menu object. You'll need to calculate those coordinates, but you might be able to do this easily without subclassing ComboBox.

我正在用 PopUpButton 做类似的事情;您可能会发现使用 PopUpButton 更容易.这是基于我当前项目的真实代码:

I am doing something similar with PopUpButton; you might find it easier to work with PopUpButton. This is based on real code from my current project:

private function initMenu(): void {
    var m:Menu = new Menu();
    m.dataProvider = theMenuData;
    m.addEventListener(MenuEvent.ITEM_CLICK, menuClick);
    m.showRoot = false;
    // m.x = ... <-- probably don't need to tweak this.
    // m.y = ... <-- this is really the interesting one :-)
    theMenu.popUp = m;
}
<mx:PopUpButton id="theMenu" creationComplete="initMenu()" ... />

顺便说一句,为了让 PopUpButton 表现得更像我想要的(总是弹出,无论点击哪里),在 MXML 中设置 openAlways=true 就像一个魅力.

BTW, to get the PopUpButton to act more like I wanted it (always popup, no matter where the click), setting openAlways=true in the MXML works like a charm.

这篇关于Flex - 有没有办法指定 ComboBox 将打开的方向?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆