tag:robotlegs.tenderapp.com,2009-10-18:/discussions/solutions/977-robotlegs-2-calloutbutton-content-mediationRobotlegs: Discussion 2014-12-17T15:15:29Ztag:robotlegs.tenderapp.com,2009-10-18:Comment/282237892013-08-12T16:10:59Z2013-08-12T16:15:18ZRobotlegs 2: CalloutButton content mediation<div><p>Nothing too complicated, but took me some time to figure
out.<br>
Here's an example:</p>
<p><em>ConnectionButton.mxml</em></p>
<pre>
<code><?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></code>
</pre>
<p><em>ConnectionButtonMediator.as</em></p>
<pre>
<code>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);
}
}
}</code>
</pre>
<p>Hope this helps!</p></div>Quentintag:robotlegs.tenderapp.com,2009-10-18:Comment/282237892013-08-12T16:40:42Z2013-08-12T16:40:42ZRobotlegs 2: CalloutButton content mediation<div><p>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
<code>mediatorMap.mediate</code> to
<code>viewManager.addContainer</code>.</p></div>Shaun Smithtag:robotlegs.tenderapp.com,2009-10-18:Comment/282237892013-08-13T08:34:29Z2013-08-13T08:34:29ZRobotlegs 2: CalloutButton content mediation<div><p>Well unfortunately no, that really doesn't work...</p>
<p>The first time you open the callout it shows the callout content
and <strong>then</strong> adds the container to the view manager,
so the content is not mediated.</p>
<p>The second time you open the callout its content is
<strong>shown and mediated.</strong></p>
<p>There's some kind of race condition happening here. Don't know
which event to listen to to prevent this from happening. Any
suggestion?</p></div>Quentintag:robotlegs.tenderapp.com,2009-10-18:Comment/282237892013-08-14T10:26:03Z2013-08-14T10:26:03ZRobotlegs 2: CalloutButton content mediation<div><p>Sorry, I haven't forgotten about this.. just busy at the mo.</p>
<p>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.</p></div>Shaun Smithtag:robotlegs.tenderapp.com,2009-10-18:Comment/282237892013-08-14T10:34:01Z2013-08-14T10:34:01ZRobotlegs 2: CalloutButton content mediation<div><p>Cool, not an urgent issue.</p></div>Quentintag:robotlegs.tenderapp.com,2009-10-18:Comment/282237892013-09-12T12:58:01Z2013-09-12T12:58:01ZRobotlegs 2: CalloutButton content mediation<div><p>Hey again!<br>
Did you have time to look into this?</p>
<p>Thanks!</p></div>Quentin