NSCell是如何显示的?
NSControl 的单元格不在视图层次结构中。我说得对吗?
如果不是,如果它不在视图层次结构中,如何在视图上绘制它?
我问这个问题是因为我想要一个视图/控件子类,我可以将其拖到内容视图上,然后将按钮添加到该视图中,并将最低组件作为单元格。因此单元格可以获取所有点击事件,执行某些操作,然后将它们传递到按钮上。
窗口->ContentView-> CustomView ->(按钮,按钮,按钮)
NSResponder,谢谢,这就是我的想法。
Costique,我总是先检查苹果的文档。我只是想寻求澄清。
An NSControl's cell isn't in the view hierarchy. Am I correct?
If it isn't, how is it being drawn on the view if it's not in the view hierarchy?
I ask because I want to have a View/Control subclass that I can drag out onto a contentview, then add buttons into that view, and have the lowest component be the cell. So the cell can get all the click events, do something, then pas them onto the buttons.
Window ->ContentView -> CustomView ->(Button, Button, Button)
NSResponder, thanks thats what I thought.
Costique, I always check apple's docs first. I was just looking for clarification.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
阅读 Apple文档。简而言之,控件的 -drawRect: 将 -drawInteriorWithFrame:inView: 和/或 -drawWithFrame:inView: 发送到执行实际绘图的单元格。
Read Apple's docs. In a nutshell, a control's -drawRect: sends -drawInteriorWithFrame:inView: and/or -drawWithFrame:inView: to its cell which does the actual drawing.
单元格不是视图,它在视图层次结构中没有位置。您应该将单元格视为视图使用来绘制视图内容的一部分并处理某些事件的东西。
单元格存在的原因是视图有些重量级。
A cell is not a view, it has no place in the view hierarchy. You should think of a cell as something that a view uses to draw a portion of the view's contents, and to handle certain events.
The reason that cells exist, is that views are somewhat heavyweight.