示例#1
0
 public override void NeedsUpdate(NSMenu menu)
 {
     // MacOS calls this for each menu when it's about to open, but also for every menu on every keystroke.
     // We only want to do the update when the menu's about to open, since it's expensive. Checking whether
     // NSMenuProperty.Image needs to be updated is the only way to distinguish between these cases.
     //
     // http://www.cocoabuilder.com/archive/cocoa/285859-reason-for-menuneedsupdate-notification.html
     //
     if (menu is MDMenu mdMenu && menu.PropertiesToUpdate().HasFlag(NSMenuProperty.Image))
     {
         mdMenu.UpdateCommands();
     }
 }