ComboBox direction

I needed to force the Flex ComboBox to open in a specific direction. (I’m using a HTML Component FCKEditor, which has to be on top, so I need to aim the ComboBox away from it, so it doesn’t animate underneath it)

It seems as though the only way to do this in Flex is to edit the mx.controls.ComboBox class itself. With some help from typeoneerror, I went ahead and did just that:

i added two booleans to the class to use to force the comboBox’s direction:

[sourcecode language=”actionscript3″]
public var forceDirectionDown:Boolean = false;
public var forceDirectionUp:Boolean = false;
[/sourcecode]

now in the displayDropdown method, inside the ‘opening the dropdown’ section, i just changed the if statement:

[sourcecode language=”actionscript3″]
if (forceDirectionUp || (!forceDirectionDown &&
point.y + _dropdown.height > screen.height &&
point.y > _dropdown.height))
[/sourcecode]

There is still a problem, however – when I set the Combo to ‘forceDirectionDown’ and there isn’t enough room at the bottom of the screen, when the dropdown closes, it assumes to animate the dropdown down, away from the combo. To resolve this, I added to the ‘closing the dropdown’ section, where it sets endY. I changed the condition line to:

[sourcecode language=”actionscript3″]
endY = (forceDirectionUp || (!forceDirectionDown &&
(point.y + _dropdown.height > screen.height || tweenUp))
[/sourcecode]

Unknown's avatar

iOS development with Swift - book: https://manning.com/books/ios-development-with-swift video course: https://www.manning.com/livevideo/ios-development-with-swift-lv

Tagged with:
Posted in Flex

Leave a Reply

Discover more from Before I forget...

Subscribe now to keep reading and get access to the full archive.

Continue reading