For a PopUpButton, I need to throw an event. Unfortunately, if you dispatch an event directly in the itemClickHandler, the menu is frozen on the screen. I couldn’t find a way to scroll the menu up anymore. So I made up the hack bellow: Basically, I defer the dispatch of the event to the calllater method of the UIComponent.
...
popUpButton.popUp = createMenu(pageLeaf.*)
}
private function createMenu( menuXML : XMLList ) : Menu
{
var currentMenu : Menu = new Menu()
currentMenu.dataProvider = menuXML
currentMenu.labelField = "@label"
currentMenu.addEventListener(MenuEvent.ITEM_CLICK, itemClickHandler )
return currentMenu
}
private function itemClickHandler(e:MenuEvent) : void
{
var event : PageEvent = new PageEvent(PageVO.GET, e.item.@pagenumber)
this.callLater(dispatchCairngormEvent, [event]) }
private function dispatchCairngormEvent(event: PageEvent): void
{
event.dispatch()
}
I’m thankful for any comments, improvements, explanations, etc…