tag:robotlegs.tenderapp.com,2009-10-18:/discussions/questions/76-robotlegs-air-application-with-standard-top-menu-barRobotlegs: Discussion 2018-10-18T16:35:09Ztag:robotlegs.tenderapp.com,2009-10-18:Comment/11221822010-03-04T08:06:10Z2010-03-04T08:06:10ZRobotlegs AIR application with standard top menu bar?<div><p>I haven't seen anything related to the menu bar in terms of
demos. It should just mediate though (as well as individual items
if you need that sort of granularity.)</p></div>Joel Hookstag:robotlegs.tenderapp.com,2009-10-18:Comment/11221822010-03-15T23:22:36Z2010-09-19T12:42:44ZRobotlegs AIR application with standard top menu bar?<div><p>I've done exactly this recently. Unfortunately the app isn't finished so I can't show an example.</p>
<p>Basically I have a mediator which mediates my main WindowedApplication. The mediator gains access to the menu via a public exposed property.</p></div>willdadytag:robotlegs.tenderapp.com,2009-10-18:Comment/11221822010-03-15T23:44:50Z2010-03-15T23:44:52ZRobotlegs AIR application with standard top menu bar?<div><p>Hi Will and Joel,</p>
<p>Thanks. I will post a small example somewhere when I get a
chance. Been using Robotlegs for a week or two on a new
application. It is so great to have dependency injection in
AS3!<br>
-r</p></div>RichSadtag:robotlegs.tenderapp.com,2009-10-18:Comment/11221822010-03-16T04:28:31Z2010-03-16T04:28:31ZRobotlegs AIR application with standard top menu bar?<div><p>I was testing this out a bit and you can in fact mediate the
NativeMenu.</p>
<pre>
public class TestContext extends Context
{
override public function startup():void
{
mediatorMap.mapView(NativeMenu, MenuMediator);
mediatorMap.mapView(TestMediateMenu, AppMediator);
}
}
</pre>
<pre>
public class AppMediator extends Mediator
{
[Inject]
public var view:TestMediateMenu;
override public function onRegister():void
{
mediatorMap.createMediator(view.nativeApplication.menu);
}
}
</pre>
<p>Couple things to keep in mind is that NativeMenu is NOT a
DisplayObject and doesn't fire an ADDED_TO_STAGE event. In fact,
the menu is already made when the app is initialized. To get it
mediated you want to mediate it prior to mediating the application
itself. In the Application mediator's onRegister you then have to
manually create the mediator for the menu. This general process
would also work for menu items.</p>
<p>This was just a half-assed attempt at this to see if it would
work. Enough to get started though I hope.</p></div>Joel Hookstag:robotlegs.tenderapp.com,2009-10-18:Comment/11221822010-03-16T10:49:46Z2010-03-16T10:49:50ZRobotlegs AIR application with standard top menu bar?<div><p>That's fantastic Joel. Thanks. I'm enjoying Robotlegs and hoping
to contribute something back to the community.</p></div>RichSadtag:robotlegs.tenderapp.com,2009-10-18:Comment/11221822010-08-28T21:09:00Z2010-08-28T21:10:57ZRobotlegs AIR application with standard top menu bar?<div><p>This method didn't work for me, but I found one that does:</p>
<p>In my AppMediator:</p>
<pre><code>override public function onRegister() : void {
var appMenu:AppMenu = new AppMenu(contextView.stage);
mediatorMap.createMediator(NativeApplication.nativeApplication.openedWindows[0].menu);
}</code></pre>
<p>I couldn't get access to the nativeApplication.menu, but thanks to MonsterDebugger I found it easily available through the openedWindows array.</p>
<p>The AppMenu class extends NativeMenuItem and generates the menu for the application (hence the need to inject the Stage).</p></div>surya