[Mono-osx] How to work with Main Menu?

Miguel de Icaza miguel at novell.com
Wed Dec 22 23:18:17 EST 2010


I'm struggling to figure out how to work with the Main Menu. I've worked
> through the tutorial and learned how to attach events and how to setup items
> to show up in the Main Window. I can click on buttons and update labels etc.
> I'm trying to do the same for MainMenu but it doesn't have a Main Menu
> Controller like the Main Window Controller that the main window has.
> How do I write code for clicks on menu items?

I have not tested these steps, but the last time I did something like this
it was very easy.

You connect the "Sent Action" in the UI to a target.   This can be any of
your File Owner (the MainMenu.cs), the First Responder (it would route this
to whoever has the focus at this point) or the AppDelegate (a convenient
place to put it).

For each of the actions that you receive, merely decorate your method with
an [Export] attribute, like this:

[Export ("newDocument:")]
public void NewDocument () {}

This is convenient because the default menu already has a "newDocument:" in
there, for your own items, just hook up the Sent action manually.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.ximian.com/pipermail/mono-osx/attachments/20101222/6ebebdd2/attachment.html 

More information about the Mono-osx mailing list