Quick update - I've made some good progress in sorting this out. I needed to
add the following code:
To the MDIWindowControlsContainer sub-class:
private function dropDownMenuBtn_click(event:MouseEvent):void {
window.dispatchEvent(new Event("menuClick"));
}
To my panel:
parent.addEventListener("menuClick", refreshData);
If there is a more elegant or preferred method please let me know!
--- In [email protected], "edlueze" <edlu...@...> wrote:
>
> I want to be able to create a custom menu in each of my FlexMDI windows. I've
> implemented some code to put the menu button on the title bar but now I'm
> stuck.
>
> I've been following an example which demonstrates how to build a menu from
> within a sub-class of MDIWindowControlsContainer. That works fine, but now I
> want the menu to be controlled by code within the panel - not from within the
> sub-class. I've been trying to generate Events from the extended
> MDIWindowControlsContainer (I don't want to mess with the other classes) but
> I can't figure it out.
>
> How can I catch the custom menu button click event from my panel?
>
> Here's some of the code I added to the MDIWindowControlsContainer sub-class:
>
> override protected function createChildren():void
> {
> //Call super.createChildren() to first create closeBtn,
> minimizeBtn, and maximizeRestoreBtn
> super.createChildren();
>
> //Create the custom drop-down menu button
> dropDownMenuBtn = new Button();
> dropDownMenuBtn.width = 12;
> dropDownMenuBtn.height = 12;
> dropDownMenuBtn.styleName = "mdiDropDownMenuButton";
>
> dropDownMenuBtn.addEventListener(MouseEvent.CLICK,dropDownMenuBtn_click);
> this.addChild(dropDownMenuBtn);
> }
>
> private function dropDownMenuBtn_click(event:MouseEvent):void
> {
> var menu : Menu = Menu.createMenu(this,this.mdp,false);
> menu.labelField = "@label";
> menu.addEventListener(MenuEvent.ITEM_CLICK,onClickMenu);
> menu.show( event.stageX - 5, event.stageY + 5 );
> }
>
> private function onClickMenu(event:MenuEvent):void
> {
> // The example says "implement super cool button logic here" but
> I don't want to - I want the logic to sit next to all of the panel components
> }
>
> private var mdp : XML = <root>
> <menuitem label="Pin To Desktop" eventName="pin"/>
> <menuitem label="Edit Settings" eventName="settings"/>
>
> </root>;
>