1 Reply Latest reply on Sep 10, 2008 7:23 AM by Newsgroup_User

    Sharing Events/Handlers for Tree and List

    ericbelair Level 1
      I have a Tree component and a List component that both share very similar functionality. In particular, I have setup functionality to edit the labels in each component only when I trigger a custom event from a ContextMenu, preventing the default action of editing the item when it is selected.

      Since Tree extends List, I was wondering if there was some easy way to make a Class/Component that could contain all the logic for this functionality that could be shared across Tree and List (or any List-based) components.

      I'm basically trying to avoid duplicating code.

      Any thoughts/suggestions?

      Thanks!
        • 1. Re: Sharing Events/Handlers for Tree and List
          Level 7

          "ericbelair" <webforumsuser@macromedia.com> wrote in message
          news:ga8h3q$9pn$1@forums.macromedia.com...
          >I have a Tree component and a List component that both share very similar
          > functionality. In particular, I have setup functionality to edit the
          > labels in
          > each component only when I trigger a custom event from a ContextMenu,
          > preventing the default action of editing the item when it is selected.
          >
          > Since Tree extends List, I was wondering if there was some easy way to
          > make a
          > Class/Component that could contain all the logic for this functionality
          > that
          > could be shared across Tree and List (or any List-based) components.
          >
          > I'm basically trying to avoid duplicating code.
          >
          > Any thoughts/suggestions?

          I think what you're looking for is called "monkey patching", which involves
          putting a file of the same name and directory structure in your project as
          the original was in the Framework. I don't know much more about it than
          that, though.