确定 NSOpenPanel 何时关闭
我试图确定 NSOpenPanel 在实际关闭之前何时关闭。我需要这样做,这样我就可以覆盖另一个窗口,并在其顶部打开打开面板的屏幕截图以进行动画处理。不幸的是,您似乎能够访问的所有通知似乎都会在窗口关闭后触发。这会导致在开始转换之前出现令人不快的口吃。
我尝试过:
- 在打开的面板上使用 NSWindow 委托方法(显然,所有 NSWindow 委托方法都不起作用)
- 监控面板:userEnteredFilename:confirmed: (未调用)
- 显示带有回调的对话框(回调在面板消失后发生)
I'm trying to determine when an NSOpenPanel is closing before it actually closes. I need to do this so I can overlay another window with a screenshot of the open panel on top of it to be animated. Unfortunately, all the notifications that you seem to be able to access seem to fire AFTER the window's already been closed. This leads to a jarring stutter before you start your transition.
I've tried:
- using NSWindow delegate methods on the open panel (apparently, none of the NSWindow delegate methods work)
- monitoring panel:userEnteredFilename:confirmed: (not called)
- showing the dialog with a callback (callback happens AFTER the panel disappears)
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
您应该将控制器注册为打开面板的委托,然后实现
-panel:isValidFilename:
委托方法。该方法将在打开的对话框关闭之前调用。如果您只需要通知,您应该从该方法返回
YES
。返回NO
允许您阻止打开的对话框被关闭。You should register your controller as the open panel's delegate and then implement the
-panel:isValidFilename:
delegate method. This method will be called just before the open dialog closes.You should return
YES
from the method if you just want the notification. ReturningNO
allows you to prevent the open dialog from being closed.处理这个问题的另一种方法是查看 NSOpenPanel 的子视图中的“取消”按钮,然后将自己替换为目标/操作。这就是我最终所做的。
Another way to handle this was to look through NSOpenPanel's subviews for the Cancel button and swap yourself in as the target/action. This is what i ended up doing.