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:

public var forceDirectionDown:Boolean = false;
public var forceDirectionUp:Boolean = false;

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

if (forceDirectionUp || (!forceDirectionDown &&
point.y + _dropdown.height > screen.height &&
point.y > _dropdown.height))

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:

endY = (forceDirectionUp || (!forceDirectionDown &&
(point.y + _dropdown.height > screen.height || tweenUp)) 

Interactive developer, Author - iOS development with Swift - book coming 2017 https://manning.com/books/ios-development-with-swift

Tagged with:
Posted in Flex

Leave a Reply

Please log in using one of these methods to post your comment:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: