从NSToolbarItem按钮显示NSPopover [英] Show NSPopover from NSToolbarItem Button

查看:251
本文介绍了从NSToolbarItem按钮显示NSPopover的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想从工具栏中的NSToolbarItem按钮显示NSPopover.
(即位于按钮下方).

I want to show an NSPopover from an NSToolbarItem button in my toolbar.
(i.e. positioned below the button).

理想情况下,我想将按钮的NSView传递到弹出框以将其定位.
我的问题是,如何获得NSToolbarItemNSView?

Ideally, I want to pass the NSView of the button to the popover to position it.
My question is, how do I get the NSView of the NSToolbarItem?

[toolbarbutton view]始终返回nil.

推荐答案

答案似乎在2011年WWDC会议113全屏和水上变化"的视频中.基本上,将NSButton放在NSToolbaritem内并使用其视图.

The answer appears to be in the video for the 2011 WWDC Session 113, "Full Screen and Aqua Changes." Basically, put an NSButton inside the NSToolbaritem and use the view of that.

此处是博客文章: http://www.yellowfield.co.uk/blog/?p = 33 ,示例项目位于github上的 http://github.com/tevendale/ToolbarPopover

A blog post is here: http://www.yellowfield.co.uk/blog/?p=33, and a sample project is on github at http://github.com/tevendale/ToolbarPopover

全部来自 http://xkcd.com/979

这篇关于从NSToolbarItem按钮显示NSPopover的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆