Disconnect the NSMenuItem plugged in using Xamarin.Mac

How to disable NSMenuItem? I am trying to disable NSMenuItem after clicking it. A click is handled correctly using Action.

I tried changing the property Enabledto false in the following two ways:

partial void Logout (AppKit.NSMenuItem sender)
{
   sender.Enabled = false;
}

and

partial void Logout (AppKit.NSMenuItem sender)
{
   LogoutItemOutlet.Enabled = false;
}

But every time this action is called, the fields Enabledare saved true. The menu item itself also never turns off.

How to disable NSMenuItem after completing an action?

+4
source share
2 answers

Try setting the menu item Actionto null:

partial void Logout (AppKit.NSMenuItem sender)
{
   LogoutItemOutlet.Action = null;

   // I don't think you need the following but it won't hurt
   LogoutItemOutlet.Enabled = false;
}
+4
source

NSMenuItem Enabled , NSMenu, , AutoEnablesItems, true ( false). Interface Builder.

0

Source: https://habr.com/ru/post/1625143/


All Articles