开发者

Disable toggleToolbarShown: for Preferences panel in a Mac (Cocoa) app?

I'm working 开发者_开发技巧on a Mac app that uses a toolbar in it's main window. In the menu there is an item that allows the user to show or hide the toolbar. In Interface Builder this menu item is connected to the toggleToolbarShown: method of First Responder in my MainMenu.xib. FWIW, my main window is in a different xib and toggleToolbarShown: is correctly called on it when it is the frontmost window.

My app has a preferences panel that also has a toolbar. However, I don't want the user to be able to toggle the toolbar on this panel. As it stands, the show/hide menu item does allow toggling of the preference toolbar when the preference window is frontmost since it goes through First Responder.

How do I disable this behavior for just the preference panel, but not the main window?


You can use an NSWindow subclass for your preferences window, and disable the menu item from there. See Camino's PreferencesWindow, which does exactly what you want to do. You'll also want to call setShowsToolbarButton:NO on the window, if you aren't already doing that.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜