Flex的 - 有没有一种方法来指定哪些方向的组合框将打开?组合、方法来、方向、Flex

2023-09-08 15:37:41 作者:一個人的生活

也许我应该进一步验证这一点 - 有没有一种方法来指定方向的组合框将打开没有复制和粘贴整个ComboBox类,并剥开code其中它确定哪个方向,将在开...

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...

推荐答案

如果你建立菜单对象自己,你可以把你想通过简单的设置x,菜单对象的y坐标菜单中的任何地方。你需要计算这些坐标,但你也许能够很容易地做到这一点没有继承组合框。

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.

我在做类似的事情有弹出式按钮;你可能会发现很容易与弹出式按钮的工作。这是从我当前的项目基于真实code:

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()" ... />

顺便说一句,让弹出式按钮来更像我想它(总是弹出,无论身在何处的点击),设置openAlways =在MXML真正用得好好的。

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.