{"id":796,"date":"2011-12-05T04:52:26","date_gmt":"2011-12-05T03:52:26","guid":{"rendered":"http:\/\/www.malcolmhardie.com\/weblogs\/angus\/?p=796"},"modified":"2025-02-01T03:04:14","modified_gmt":"2025-02-01T03:04:14","slug":"versions-validatemenuitem-and-nsmenuitem","status":"publish","type":"post","link":"https:\/\/www.malcolmhardie.com\/weblogs\/angus\/2011\/12\/05\/versions-validatemenuitem-and-nsmenuitem\/","title":{"rendered":"Versions, validateMenuItem: and NSMenuItem"},"content":{"rendered":"<p>If you find when developing in 10.7 that you get a versions menu with a NSMenuItem as one of the items, it might be worth checking to see whether you&#8217;re correctly using validateMenuItem:<\/p>\n<p><a href=\"https:\/\/oak.malcolmhardie.com\/weblogs\/angus\/wp-content\/uploads\/2011\/07\/versions.png\"><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-800\" title=\"versions\" src=\"https:\/\/oak.malcolmhardie.com\/weblogs\/angus\/wp-content\/uploads\/2011\/07\/versions.png\" alt=\"\" width=\"330\" height=\"126\" \/><\/a><\/p>\n<p>This problem may happen if you return YES from validateMenuItem in a NSDocument subclass for menu items that you don&#8217;t actually control. (If you just return YES as a default for example)<\/p>\n<p>If instead you return<\/p>\n<p><code>[super validateMenuItem:item]<\/code><\/p>\n<p>You should get the correct &#8220;Revert to Last Saved Version&#8221; menu item<\/p>\n<p><a href=\"https:\/\/oak.malcolmhardie.com\/weblogs\/angus\/wp-content\/uploads\/2011\/07\/versions-good.png\"><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-802\" title=\"versions-good\" src=\"https:\/\/oak.malcolmhardie.com\/weblogs\/angus\/wp-content\/uploads\/2011\/07\/versions-good.png\" alt=\"\" width=\"341\" height=\"119\" \/><\/a><\/p>\n<p>I ran into this when I was doing testing on 10.7 and although documentation clearly states that you must call the super method in validateMenuItem: , it wasn&#8217;t immediately obvious to me what was causing the problem.<\/p>\n<p>Hope this helps if you have the same problem.<\/p>\n<p><strong>Edit:<\/strong> This may have been fixed in OS X<\/p>\n","protected":false},"excerpt":{"rendered":"<p>If you find when developing in 10.7 that you get a versions menu with a NSMenuItem as one of the items, it might be worth checking to see whether you&#8217;re correctly using validateMenuItem: This problem may happen if you return YES from validateMenuItem in a NSDocument subclass for menu items that you don&#8217;t actually control. [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[10,12],"tags":[],"class_list":["post-796","post","type-post","status-publish","format-standard","hentry","category-macintosh","category-sqleditor"],"_links":{"self":[{"href":"https:\/\/www.malcolmhardie.com\/weblogs\/angus\/wp-json\/wp\/v2\/posts\/796","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.malcolmhardie.com\/weblogs\/angus\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.malcolmhardie.com\/weblogs\/angus\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.malcolmhardie.com\/weblogs\/angus\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.malcolmhardie.com\/weblogs\/angus\/wp-json\/wp\/v2\/comments?post=796"}],"version-history":[{"count":1,"href":"https:\/\/www.malcolmhardie.com\/weblogs\/angus\/wp-json\/wp\/v2\/posts\/796\/revisions"}],"predecessor-version":[{"id":1328,"href":"https:\/\/www.malcolmhardie.com\/weblogs\/angus\/wp-json\/wp\/v2\/posts\/796\/revisions\/1328"}],"wp:attachment":[{"href":"https:\/\/www.malcolmhardie.com\/weblogs\/angus\/wp-json\/wp\/v2\/media?parent=796"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.malcolmhardie.com\/weblogs\/angus\/wp-json\/wp\/v2\/categories?post=796"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.malcolmhardie.com\/weblogs\/angus\/wp-json\/wp\/v2\/tags?post=796"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}