通过背景移动 NSPanel 并在其上添加一些 NSView
我有一个 NSPanel。当面板为空时,通过按住并拖动其背景可以很好地移动。但是,如果我在上面放一些东西,新视图覆盖的区域将不再可拖动。例如,我可以将 NSImageView 完全填充面板。并且面板不再被拖动。不过,我想让这个即使用户按住图像视图也可以拖动。我应该怎么做才能做到这一点?
I have a NSPanel
. When the panel is empty, is moves well with holding and dragging it's background. However, If I put something on it, the area covered by new view won't be draggable anymore. As an example, I could put a NSImageView
fills the panel fully. And the panel do not being dragged anymore. However I want to make this draggable even user holding on the image view. What should I do to do this?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您必须对
NSImageView
进行子类化并实现- (BOOL)mouseDownCanMoveWindow
返回YES
。然后您就可以将窗口拖动到您单击的任何位置。You have to subclass your
NSImageView
and implement- (BOOL)mouseDownCanMoveWindow
to returnYES
. Then you'll be able to drag the window wherever you click.