3 Replies Latest reply on Jun 25, 2011 2:05 AM by stujk

    How to set group to exclude particular child when responding to mouse activity?

    stujk

      Hi, I have the following situation:

       

      situation.png

      Group B is underneath Group A.

       

      The label is a child of Group A. I want the label to completely ignore any mouse events, so they are handled by Group B (not Group A).

       

      I'm aware of "mouseEnabled", but setting this on the label to false means the events are dispatched from Group A instead (which makes sense, it's just not what I want). I can't set mouseEnabled to false on the whole of Group A because it has other components that use the mouse.

       

      If I set "mouseEnabledWhereTransparent" to false on the label, mouse events on the transparent part of the label are handled by Group B... that's half what I want, it's just that I want the non-transparent part of the label to ignore the mouse too!

       

      Thanks in advance for any help.

        • 1. Re: How to set group to exclude particular child when responding to mouse activity?
          Flex harUI Adobe Employee

          There is no way to do this with the configuration and goals you describe.

          The two options I can think of are:

           

          1) don't parent label in Group A.  You can float it the label over its

          current position, and even put another completely transparent placeholder

          component under the label if you need to (to help compute size and position

          of the floating label)

           

          2) catch the events on the Label and forward them to groupB.  If you know

          what the target will be it is a bit easier, otherwise you might have to use

          getObjectsUnderPoint or hitTestPoint

          • 2. Re: How to set group to exclude particular child when responding to mouse activity?
            stujk Level 1

            Thanks, I decided to float it, the second option would break encapsulation.

            I ended up doing the following:

             

            1. Wrapped the label in <fx:Declarations>.
            2. Ensured "mouseEnabled" and "mouseChildren" were set to false on the label.
            3. Added a function called by "creationComplete" in Group A's skin.
            4. The function adds the label to systemManager.popUpChildren.
            5. The function gets the global position of Group A (via localToGlobal) and adds this to the label's X and Y position (i.e. floats it above Group A, uses the label's initial X and Y position as an offset).
            6. I also added a function to "removedFromStage" to remove the label from systemManager.popUpChildren.

             

            This now looks exactly as it did before, but the label completely ignores mouse activity. So it's a workaround, but it works.

            • 3. Re: How to set group to exclude particular child when responding to mouse activity?
              stujk Level 1

              Actually, after testing I realised that doesn't take Group A moving into account, so I used a "initialize" listener to store the label's initial position, then added a "move" listener that uses the method above to position the label.