<html><head><meta http-equiv="Content-Type" content="text/html charset=us-ascii"></head><body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;">Hi all (or at least those who care about the OS X port),<div><br></div><div>I noticed yesterday that when using SDL2 the menus in the menubar are incorrect. I get an app menu with a "Fullscreen" item, then a menu without a title that is our app menu and finally our Windows menu. The issue is in the file backends/platform/sdl/macosx/appmenu_osx.mm</div><div><br></div><div>First I should note that we use NSApplication setAppleMenu: to set the app menu. But this call actually doesn't do anything for me. It seems that it just uses whatever is the menu at index 0 as app menu. This might be why setAppleMenu was removed from the header file in OS X 10.4 and maybe we could remove this call and the hack that goes with it.</div><div><div style="margin: 0px; font-size: 11px; font-family: Menlo; color: rgb(0, 132, 0);">// Apple removed setAppleMenu from the header files in 10.4,</div><div style="margin: 0px; font-size: 11px; font-family: Menlo; color: rgb(0, 132, 0);">// but as the method still exists we declare it ourselves here.</div><div style="margin: 0px; font-size: 11px; font-family: Menlo; color: rgb(0, 132, 0);">// Yes, this works :)</div><div style="margin: 0px; font-size: 11px; font-family: Menlo;"><span style="color: #bb2ca2">@interface</span> NSApplication(MissingFunction)</div><div style="margin: 0px; font-size: 11px; font-family: Menlo;">- (<span style="color: #bb2ca2">void</span>)setAppleMenu:(NSMenu *)menu;</div><div style="margin: 0px; font-size: 11px; font-family: Menlo; color: rgb(187, 44, 162);">@end</div></div><div><br></div><div>But that is secondary, and this call doesn't seem to do any harm anyway.</div><div><br></div><div>The issue is that in our code we do the following to remove the menus set by SDL:</div><div><div style="margin: 0px; font-size: 11px; font-family: Menlo; color: rgb(0, 132, 0);"><span class="Apple-tab-span" style="white-space:pre">  </span>// For some reason [[NSApp mainMenu] removeAllItems] doesn't work and crashes, so we need</div><div style="margin: 0px; font-size: 11px; font-family: Menlo; color: rgb(0, 132, 0);"><span style="color: #000000"><span class="Apple-tab-span" style="white-space:pre">    </span></span>// to remove the SDL generated menus one by one</div></div><div><div style="margin: 0px; font-size: 11px; font-family: Menlo;"><span class="Apple-tab-span" style="white-space:pre">      </span>[[NSApp mainMenu] removeItemAtIndex:<span style="color: #272ad8">0</span>];<span class="Apple-tab-span" style="white-space:pre">           </span><span style="color: #008400">// Remove application menu</span></div><div style="margin: 0px; font-size: 11px; font-family: Menlo;"><span class="Apple-tab-span" style="white-space:pre">     </span>[[NSApp mainMenu] removeItemAtIndex:<span style="color: #272ad8">0</span>];<span class="Apple-tab-span" style="white-space:pre">           </span><span style="color: #008400">// Remove "Windows" menu</span></div></div><div><br></div><div>But when using SDL2 we actually have three menus, so what I see as app menu is actually the remaining SDL2 menu ("Views", but renamed as "ScummVM" when used as app menu, and which apparently only contains a "Fullscreen" menu item). I have two alternative code that work with both SDL1 and SDL2 on OS X 10.9 and 10.10. But since I cannot test on old systems I would appreciate any feedback on if I should do a change, and which one. Currently I would tend to just add a comment for now and wait until after the next release (which I assume will be using SDL1.2) to make sure I do not break SCummVM on old systems.</div><div><br></div><div>The first things that works for me is to use:</div><div><div style="margin: 0px; font-size: 11px; font-family: Menlo;"><span class="Apple-tab-span" style="white-space:pre">       </span>[[NSApp mainMenu] removeAllItems];</div></div><div><br></div><div>Indeed for me that works and that does not cause a crash. But the comment in our current code worries me.</div><div><br></div><div>The second things that works is:</div><div><div style="margin: 0px; font-size: 11px; font-family: Menlo;"><span style="color: #bb2ca2"><span class="Apple-tab-span" style="white-space:pre">  </span>while</span> ([NSApp mainMenu].numberOfItems > <span style="color: #272ad8">0</span>) {</div><div style="margin: 0px; font-size: 11px; font-family: Menlo;"><span class="Apple-tab-span" style="white-space:pre">           </span>[[NSApp mainMenu] removeItemAtIndex:<span style="color: #272ad8">0</span>];</div><div style="margin: 0px; font-size: 11px; font-family: Menlo;"><span class="Apple-tab-span" style="white-space:pre">        </span>}</div></div><div><br></div><div>But I don't know if that works on old system (if removeAllItems crashes, I suppose that code could crash as well).</div><div><br></div><div>So does anybody have any though on that?</div><div><br></div><div>Thierry</div></body></html>