[Mono-osx] Enabling menu items
Jon Lipsky
jon.lipsky at elevenworks.com
Thu Apr 5 19:43:24 UTC 2012
Have you tried implementing the "validateMenuItem:" method in your first responder? For example, if this is an document based application, you can place the following into your NSDocument subclass:
[Export("validateMenuItem:")]
public bool ValidateMenuItem (NSMenuItem object)
{
var menuActionId = object.Action.Name;
if ("yourActionNameHere:".equals(menuActionId))
{
// Return true if you want the menu item enabled.
// Return false if you want the menu item disabled
}
return false;
}
On Apr 5, 2012, at 2:30 PM, tlapse wrote:
> I have created menu items and can perform actions. But I can't figure out how
> to manually enable/disable them from my C# code.
>
> For example, have an outlet for a menu time in AppDelegate.designer.cs,
>
> [Outlet]
> MonoMac.AppKit.NSMenuItem saveAsToolStripMenuItem { get; set; }
>
> but I can't figure out how to access it from MainWindowController.
>
> Any ideas?
>
>
>
>
> --
> View this message in context: http://mono.1490590.n4.nabble.com/Enabling-menu-items-tp4535796p4535796.html
> Sent from the Mono - OSX mailing list archive at Nabble.com.
> _______________________________________________
> Mono-osx mailing list
> Mono-osx at lists.ximian.com
> http://lists.ximian.com/mailman/listinfo/mono-osx
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.ximian.com/pipermail/mono-osx/attachments/20120405/376f3c66/attachment-0001.html>
More information about the Mono-osx
mailing list