2 Replies Latest reply on May 5, 2009 1:21 PM by peteandrus

    different ContextMenu for each branch in a Tree?

    peteandrus Level 1

      i have 3 different objects in a Tree. I have 2 different ContextMenus, one pertains to each, with one having no ContextMenu. I figured i could just listen for a right-click, then assign the ContextMenu depending on what object is selected. However, i want to ask if there is a slicker way of doing this? I am of the opinion with Flex that if my task is starting to get too difficult or i'm coding too much then i'm probably overlooking something that will make my task much easier and slicker (is that a word?)

       

      any suggestions are GREATLY appreciated.

        • 1. Re: different ContextMenu for each branch in a Tree?
          _Natasha_ Level 4

          Hi,

          I know only one way for this.

          It's imposible to handle right-click event in Flex! It's reserved for showing ContextMenu and in my opinion ContextMenu is not a good idea for web applications. But about realization:

          1. Tree has a property contextMenu. You can initialize it as you want on handler for creationComplete event, for example.

          2. You should handle changing of selectedObject event and change contextMenu as you need and set handler for selecting items from this menu.

           

          Hope this helpful.

          You can ask a source examples, if you need.

          • 2. Re: different ContextMenu for each branch in a Tree?
            peteandrus Level 1

            _natasha_

             

            i did find the ContextMenuEvent.MENU_SELECT event, which is "Dispatched when a user first generates a context menu but before the contents of the context menu are displayed". I'm going to implement this functionality using this event. thanks!