将 NSToolbar 重置回默认配置

发布于 2024-07-26 15:13:42 字数 331 浏览 16 评论 0原文

我以编程方式在我的应用程序中创建一个 NSToolbar。 我刚刚向工具栏添加了一个新按钮,并将该按钮添加到工具栏的默认配置中。 当我运行我的应用程序时,默认情况下不显示新按钮。 那是因为我已经在使用该程序,并且我已经有一个 plist 文件,其中未设置显示这个新按钮。

所以我的问题是如何让工具栏将其当前配置重置回默认配置,以便我的按钮将自动显示给一直在使用该应用程序的人。

我想我可以删除 plist 文件中的条目以强制程序重新创建它们,从而使用默认配置......但我希望有一些我可以发出的命令来重置它。 我在 NSToolbar 类中没有看到一个。

谢谢你的帮助。

I programatically create an NSToolbar in my application. I just added a new button to the toolbar and added that button to the default configuration of the toolbar. When I run my application the new button is not shown by default. That's because I already have been using the program and I already have a plist file in which this new button is not setup to be shown.

So my question is how can I get the toolbar to reset its current configuration back to the default configuration so that my button will be shown automatically for people who have been using the application.

I guess I could delete the entries in the plist file to force the program to recreate them and thus use the default configuration... but I was hoping there was was some command I could issue to reset it. I didn't see one in the NSToolbar class.

Thanks for any help.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

回忆躺在深渊里 2024-08-02 15:13:42

如果您将新按钮添加到工具栏的默认配置中,则对于已自定义工具栏并将设置存储在用户默认值中的用户来说,该按钮不会显示。

如果您想对之前自定义过工具栏的用户强制使用新的默认工具栏,可以更改自动保存名称(例如,通过附加版本号)。 (不过,请考虑是否要取消用户的工具栏自定义设置。)

If you add a new button to your toolbar's default configuration it will not appear for users which have customized the toolbar and have settings stored in the user defaults.

If you want to force the new default toolbar on users which have perviously customized the toolbar, changing the autosave name (by appending a version number, for example) is the way to do so. (Consider whether you want to blow away your user's toolbar customizations though.)

源来凯始玺欢你 2024-08-02 15:13:42

嗯,我删除了 plist 文件中相应的密钥,它起作用了。 我仍然想知道更好的方法,所以如果您有任何更好的想法请告诉我。

Well I deleted the appropriate key in the plist file and it worked. I'd still rather know a better way so if you have any better ideas let me know.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文