Robotlegs 2: CalloutButton content mediation

Quentin's Avatar

Quentin

12 Aug, 2013 04:10 PM

Nothing too complicated, but took me some time to figure out.
Here's an example:

ConnectionButton.mxml

<?xml version="1.0"?>
<s:CalloutButton
        xmlns:fx="http://ns.adobe.com/mxml/2009"
        xmlns:s="library://ns.adobe.com/flex/spark"
        xmlns:views="fr.edumedia.lily.mvcs.views.*"
        label="Connection">

    <views:ConnectionForm id="connectionForm" />

</s:CalloutButton>

ConnectionButtonMediator.as

package fr.edumedia.lily.mvcs.views {

    import robotlegs.bender.bundles.mvcs.Mediator;
    import robotlegs.bender.extensions.mediatorMap.api.IMediatorMap;
    import spark.events.DropDownEvent;

    public class ConnectionButtonMediator extends Mediator {

        [Inject]
        public var view:ConnectionButton;

        [Inject]
        public var mediatorMap:IMediatorMap;

        override public function initialize():void {
            addViewListener(DropDownEvent.OPEN, mediateForm);
        }

        protected function mediateForm(e:DropDownEvent):void {
            mediatorMap.mediate(view.connectionForm);
        }

    }
}

Hope this helps!

  1. Quentin closed this discussion on 12 Aug, 2013 04:13 PM.

  2. Shaun Smith re-opened this discussion on 12 Aug, 2013 04:40 PM

  3. Support Staff 1 Posted by Shaun Smith on 12 Aug, 2013 04:40 PM

    Shaun Smith's Avatar

    Note that is won't mediate any children in your pop up view. To do that you could inject IViewManager into your mediator and change mediatorMap.mediate to viewManager.addContainer.

  4. 2 Posted by Quentin on 13 Aug, 2013 08:34 AM

    Quentin's Avatar

    Well unfortunately no, that really doesn't work...

    The first time you open the callout it shows the callout content and then adds the container to the view manager, so the content is not mediated.

    The second time you open the callout its content is shown and mediated.

    There's some kind of race condition happening here. Don't know which event to listen to to prevent this from happening. Any suggestion?

  5. Support Staff 3 Posted by Shaun Smith on 14 Aug, 2013 10:26 AM

    Shaun Smith's Avatar

    Sorry, I haven't forgotten about this.. just busy at the mo.

    I imagine that the callout is already on stage by the time addContainer is called. I'll take a look at how the StageCrawler might help here. It might take a while to free up some time though, so please remind me in a couple of days if I forget.

  6. 4 Posted by Quentin on 14 Aug, 2013 10:34 AM

    Quentin's Avatar

    Cool, not an urgent issue.

  7. 5 Posted by Quentin on 12 Sep, 2013 12:58 PM

    Quentin's Avatar

    Hey again!
    Did you have time to look into this?

    Thanks!

  8. Ondina D.F. closed this discussion on 17 Dec, 2014 03:15 PM.

Comments are currently closed for this discussion. You can start a new one.

Keyboard shortcuts

Generic

? Show this help
ESC Blurs the current field

Comment Form

r Focus the comment reply box
^ + ↩ Submit the comment

You can use Command ⌘ instead of Control ^ on Mac