简体   繁体   English

隐藏/显示NSToolbarItem的

[英]Hiding/Displaying NSToolbarItem's

I have an application with many NSToolbarItems. 我有一个带有许多NSToolbarItems的应用程序。 Only 5 or so are needed at any one time so it seems like the best way to fit them on the screen and make them easy to get to is to hide/display only the NSToolbarItems depending on the context. 一次只需要5个左右,因此使它们适合在屏幕上并使其易于使用的最佳方法似乎是根据上下文仅隐藏/显示NSToolbarItems。

I can't find either through google or in the Apple doc's how to do this. 我无法通过Google或Apple文档找到如何执行此操作的方法。 Is there a way? 有办法吗? (Short of actually writing a custom nstoolbar!) (实际编写自定义nstoolbar的简短内容!)

NB: I am worried this is a little bit "anti" the user interface standards, but I cannot think of a better way to handle large number of buttons that are all needed by the user, except maybe a tool window thingy. 注意:我担心这有点“反”用户界面标准,但是我想不出一种更好的方式来处理用户所有需要的大量按钮,除非可能是一个工具窗口。

You can go through all the items with -[NSToolbar items] , and remove unwanted ones with -[NSToolbar removeItemAtIndex:] , Although apple does say this: 您可以使用-[NSToolbar items]浏览所有项,并使用-[NSToolbar removeItemAtIndex:]删除不需要的-[NSToolbar items] ,尽管apple确实这样说:

Typically, you should not call this method ( -[NSToolbar removeItemAtIndex:] ); 通常,您不应调用此方法( -[NSToolbar removeItemAtIndex:] ); you should let the user reconfigure the toolbar. 您应该让用户重新配置工具栏。

Usually you just disable the toolbar items that can't be used in the current context. 通常,您只是禁用在当前上下文中无法使用的工具栏项。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM