2 Replies Latest reply on Apr 6, 2007 11:33 AM by endurafirst

    Is there a way to dispatch or bubble events between two pop-up windows?

    endurafirst
      Hi. I was wondering if there is a way to dispatch custom events between two or more pop-up windows created using the PopUpManager?

      I understand how to pass an event from one pop-up window to the main application (or FrontController) by dispatching the event from Application.application under Cairngorm 2.0.

      However, as I understand it, that will only bubble the event through the Application chain of visual controls and not to the other pop-up windows created using the PopUpManager.

      I tried dispatching the event directly from the pop-up window itself, but the other pop-ups still does not seem to receive the event.

      It would be nice to be able to do this so that each non-modal pop-up can have some awareness with each other.

      Thank you very much in advance.
        • 1. Re: Is there a way to dispatch or bubble events between two pop-up windows?
          peterent Level 2
          If you have just 2 pop-ups you can have them each do a addEventListener on the other, listening for the event (custom or otherwise).

          If you have an unpredicatable number, then you devise something else. Suppose you have 3 pop-ups, p1, p2, and p3. Let's say you also have 1 custom event, E1. Any of those pop-ups is capable of dispatching an E1 event and you want all of them to receive it.

          Create a class that extends EventDispatcher and instantiate an object of that class. Each pop-up "registers" with that class, something like:

          controller.addEventListener( "E1", handler ); where handler is a function in the pop-up.

          When a pop-up wants to dispatch an E1 event, it does it through the controller: controller.dispatchEvent( new E1(data) );

          This will automatically dispatch that event to all the pop-ups, including the one that dispatched the event. So a pop-up will have to examine the event to see if it sent it and perhaps ignore it.
          • 2. Re: Is there a way to dispatch or bubble events between two pop-up windows?
            endurafirst Level 1
            Hi Peter,

            Thank you for your prompt reply and help. I think I've figured it out now.

            Best regards,

            Leo