Robotlegs AIR application with standard top menu bar?

RichSad's Avatar

RichSad

Feb 28, 2010 @ 08:30 PM

HI i am new to Robotlegs and have ready the docs and looked at some of the demos. I am looking for a simple example that shows a flex-based AIR app with the standard Menu bar support on the top bar. None of the demos I've looked at include any type of standard menu. Is anyone aware of a demo with a top menu bar in an AIR app? I use Flex Builder Pro for as3 dev. Switching to robotlegs due to IoC/DI support. Thanks for any help.

  1. Support Staff 1 Posted by Joel Hooks on Mar 04, 2010 @ 08:06 AM

    Joel Hooks's Avatar

    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.)

  2. 2 Posted by willdady on Mar 15, 2010 @ 11:22 PM

    willdady's Avatar

    I've done exactly this recently. Unfortunately the app isn't finished so I can't show an example.

    Basically I have a mediator which mediates my main WindowedApplication. The mediator gains access to the menu via a public exposed property.

  3. 3 Posted by RichSad on Mar 15, 2010 @ 11:44 PM

    RichSad's Avatar

    Hi Will and Joel,

    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!
    -r

  4. Support Staff 4 Posted by Joel Hooks on Mar 16, 2010 @ 04:28 AM

    Joel Hooks's Avatar

    I was testing this out a bit and you can in fact mediate the NativeMenu.

       public class TestContext extends Context
        {
            override public function startup():void
            {
                mediatorMap.mapView(NativeMenu, MenuMediator);
                mediatorMap.mapView(TestMediateMenu, AppMediator);
                
            }
        }
    
       public class AppMediator extends Mediator
        {
            [Inject]
            public var view:TestMediateMenu;
            
            override public function onRegister():void
            {
                mediatorMap.createMediator(view.nativeApplication.menu);
            }
        }
    

    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.

    This was just a half-assed attempt at this to see if it would work. Enough to get started though I hope.

  5. Joel Hooks closed this discussion on Mar 16, 2010 @ 04:28 AM.

  6. RichSad re-opened this discussion on Mar 16, 2010 @ 10:49 AM

  7. 5 Posted by RichSad on Mar 16, 2010 @ 10:49 AM

    RichSad's Avatar

    That's fantastic Joel. Thanks. I'm enjoying Robotlegs and hoping to contribute something back to the community.

  8. 6 Posted by surya on Aug 28, 2010 @ 09:09 PM

    surya's Avatar

    This method didn't work for me, but I found one that does:

    In my AppMediator:

    override public function onRegister() : void {
            var appMenu:AppMenu = new AppMenu(contextView.stage);
            mediatorMap.createMediator(NativeApplication.nativeApplication.openedWindows[0].menu);
        }

    I couldn't get access to the nativeApplication.menu, but thanks to MonsterDebugger I found it easily available through the openedWindows array.

    The AppMenu class extends NativeMenuItem and generates the menu for the application (hence the need to inject the Stage).

  9. Stray closed this discussion on Feb 12, 2011 @ 10:50 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