2 Replies Latest reply on Feb 16, 2008 6:20 PM by Henk2

    Weird ContextMenu separator side effect

    Henk2 Level 1
      Anyone noticed some weird effect when using a separator in the ContextMenu?

      If you add a bunch of ContextMenu items and one of them has the 'separatorBefore' attribute set,
      then the event listener for the items that follow are all shifted one.

      For example, if the menu looks like this:
      (feb 16: updated the example)

      [item1, eventListener1] -> invokes eventListener1
      [item2, eventListener2] -> invokes eventListener2
      [item3, eventListener3] -> does not invoke anything
      [item4, eventListener4] -> invokes eventListener3

      Clicking on item 2 is still okay and will invoke eventListener2. Clicking on item3 does nothing, and selecting item4 invokes eventlistener3.

      If you need item 3. You're out of luck ;)
        • 1. Re: Weird ContextMenu separator side effect
          Jason Szeto Level 3
          This might be a bug. Can you file a bug at http://bugs.adobe.com/flex?
          As a workaround, maybe you can have all of the items use the same event listener. You can then find out which item is the currentTarget and then take the appropriate action.
          • 2. Weird ContextMenu separator side effect
            Henk2 Level 1
            Yes, I've created a bug for this. See: Bug SDK-14196

            It could use some votes. After six weeks there has been no response on it. I think its a pretty severe issue because not having separators makes context menu's harder to use if you have over 5 items.

            The single event handler is a smart idea, however this won't work because the event also carries the wrong contextMenuItem.

            There was a mistake in my original example. It said that item3 invokes eventlistener 4, but it won't invoke a eventlistener at all, while item4 invokes eventlistener3.
            I've updated the example.

            I found a workaround by utilizing a second bug to offset the first.

            See, if you add a ContextMenuItem which is set to invisible, the opposite happens. Now, by following an item that has a separator with an invisible item the two bugs cancel each other out: