如何在确定的 NSProgressIndicator 上停止动画?
NSProgressIndicator 允许在 isInstituteate == YES
时使用 stopAnimation:
,但是如何停止确定进度条的动画呢?
对于上下文,我尝试执行此操作的进度条是 NSView 的子级,它本身是 NSMenuItem 的 view 属性。向 setAnimationDelay:
发送高得离谱的数字可以满足我的要求,但只是暂时的——当父菜单关闭并重新打开时,进度条会再次呈现动画。
(可能是不必要的免责声明:我发誓这是一个合法的用例;我必须能够直观地(即:不使用文本)显示长时间运行的任务的进度,这些任务可能会暂停并重新启动- 根据后端的需要开始。除非附有出色的替代建议,否则不会接受归结为“UI 设计:你做得很好”的答案。
NSProgressIndicator allows stopAnimation:
when isIndeterminate == YES
, but how does one stop the animation for determinate progress bars?
For context, the progress bar I am trying to do this with is a child of an NSView, which itself is the view
property of an NSMenuItem. Sending ridiculously high numbers to setAnimationDelay:
does what I want, but only temporarily -- when the parent menu is closed and re-opened, the progress bar is animated again.
(Possibly unnecessary disclaimer: I swear this is a legit use case; I have to be able to visually (i.e.: without using text) display the progress of very-long-running tasks which may pause and re-start as needed by the backend. Answers which boil down to "UI design: ur doin it rong" will be not be accepted unless accompanied by a brilliant alternative suggestion. ;) )
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
像这样子类 NSProgressIndicator ,它也适用于 Lion:
Subclass NSProgressIndicator like this, it also works with Lion:
使用与前面描述的相同的方法解决了这个问题,但做了一个小改动。
当菜单的委托收到
menuNeedsUpdate:
时,我将setAnimationDelay:
(使用足够大的数字作为参数)发送到每个进度条。现在它工作可靠,所以我对此很满意。Solved the problem using the same approach as described previously, with one small change.
When the menu's delegate receives
menuNeedsUpdate:
, I sendsetAnimationDelay:
(with the sufficiently huge number as the arg) to each progress bar. This is working reliably now, so I'm happy enough with it.