3 Replies Latest reply on Feb 28, 2013 6:39 AM by ravid.paldi

    [Flex 4.5.1] DropDownController - how NOT to close drop down when clicked on? Example provided!

    FM_Flame Level 1

      http://www.nedyalkov.net/filip/flex_projects_tests/DropDownControllerTest/ - view source enabled

       

      When you click the button a drop down is shown. All I want to do is stop it from closing when you click on the drop down. I read a bit from the source code of the DropDownController and it seems like it should check if the mouse is clicked on the openButton or on the dropDown and if it is one of them keep the dropDown open if it's somewhere outside - close it. But in my case - when I click on the dropDown in closes itself... I tried to add it to the hitAreaAdditions... no luck the same problem.

       

      So the question is: How do I make the drop down NOT to close when clicked on?

       

      Please check my example and let me know what am I doing wrong... should be very simple but... thanks!

        • 1. Re: [Flex 4.5.1] DropDownController - how NOT to close drop down when clicked on? Example provided!
          FM_Flame Level 1

          First to correct my example - since I copied the code for the drop down from the dropDownListSkin it has includeIn="open" which causes my dropDown to be null when I set it to dropDownController.dropDown. To fix the example if you test it just remove the includeIn and autoDestructionPolicy lines.

           

          I believe I have found a bug in the DropDownController, would be nice if adobe employee confirms this or correct me if I am wrong.

           

          Here is the source function the code marked in red is with the issue:

           

          mx_internal function systemManager_mouseDownHandler(event:Event):void
              {
                  // stop here if mouse was down from being down on the open button
                  if (mouseIsDown)
                  {
                      mouseIsDown = false;
                      return;
                  }
          
                  if (!dropDown || 
                      (dropDown && 
                       (event.target == dropDown 
                       || (dropDown is DisplayObjectContainer && 
                           !DisplayObjectContainer(dropDown).contains(DisplayObject(event.target))))))
                  {
                      if (hitAreaAdditions != null)
                      {
                          for (var i:int = 0;i<hitAreaAdditions.length;i++)
                          {
                              if (hitAreaAdditions[i] == event.target ||
                                  ((hitAreaAdditions[i] is DisplayObjectContainer) && DisplayObjectContainer(hitAreaAdditions[i]).contains(event.target as DisplayObject)))
                                  return;
                          }
                      }
          
                      closeDropDown(true);
                  } 
              }
          

           

          I think these lines of code were ment to look like this (notice the black exclamation mark):

          (dropDown &&

                       (event.target != dropDown

                       || (dropDown is DisplayObjectContainer &&

                           !DisplayObjectContainer(dropDown).contains(DisplayObject(event.target)))))

          or like this (should be the same thing):

          dropDown && !(DisplayObjectContainer(dropDown).contains(DisplayObject(event.target))

           

           

          So this bug causes the drop down to close wherever you click when the event.target is the dropDown itself. Workarounds I guess are put another component in the drop down and "cover" the dropDown with it so it doesn't get any hits or use the hitAreaAdditions.


           

          Message was edited by: FM_Flame

          • 2. Re: [Flex 4.5.1] DropDownController - how NOT to close drop down when clicked on? Example provided!
            FM_Flame Level 1

            Adobe employee should check this out and fix this bug, it's very easy to fix, I don't think I need to report it for such a small mistake...

            • 3. Re: [Flex 4.5.1] DropDownController - how NOT to close drop down when clicked on? Example provided!
              ravid.paldi

              I had a similar problem.

              My work around was simple.

               

              Once all relevant objects are created(the controller and the dropDown), add the following:

              _popUpController.hitAreaAdditions = new Vector.<DisplayObject>;

              _popUpController.hitAreaAdditions.push(dropDown);

               

              Worked for me (: