1 Reply Latest reply on Jun 16, 2009 8:19 AM by leybniz

    Custom Menu Functionality

    new2:Flex

       

       

      Does anyone know of a way to keep a menu open after clicking one of its menu items?  I have a custom menu (extended the menu object) it contains a bunch of ‘check’ type menu items, the requirement I am trying to fulfill is to allow the user to click multiple menu items without the menu closing, and then have the menu close when it loses focus, is this possible? If it is can someone please explain how it can be done (pref. with a small example).

       

      Thanks in advance for any help

        • 1. Re: Custom Menu Functionality
          leybniz Level 4

          I'd recommend you to go with custom component based on top of standard mx.controls.PopUpButton;

           

          public class CheckPopupPicker extends PopUpButton {

           

            function CheckPopupPicker() {
             openAlways = true;
             setStyle("fillColors", [0xFFFFFF, 0xFFFFFF]);
             setStyle("fillAlphas", [1, 1]);
             Application.application.addEventListener(MouseEvent.MOUSE_MOVE, mouseMove);
             addEventListener(DropdownEvent.CLOSE, closeHandler);
             popUp = new VBox();
            }

           

            override protected function createChildren():void {
             super.createChildren();

             // Here add your checkboxes
             VBox(popUp).addChild(new CheckBox());
            }


            override public function initialize():void {
             super.initialize();
             BindingUtils.bindProperty(popUp, "width", this, "width");
            }


            protected function updateLabel():void {
             // Update popup button label here according to checked items
             lebel = '';
            }


            private function closeHandler(event:DropdownEvent):void {
             updateLabel();
            } 

           

            private function mouseMove(event:MouseEvent):void {
             if (event.target != this)
              close();
            }


          }