Ignoring UI Events in AppKit

谁都会走 提交于 2019-12-06 13:40:31

问题


If I wanted to ignore a touch event in UIKit on the iPhone I would simply do:

// Begin ignoring events
[[UIApplication sharedApplication] beginIgnoringInteractionEvents];
//Do my code 
// Stop ignoring events
[[UIApplication sharedApplication] endIgnoringInteractionEvents];

This allows my code in between the "ignore" calls to operate without having to worry about user interaction changing any state of the application.

My question is, how can I do this if I am writing a Mac OS X app (AppKit vs. UIKit)? I basically want to "lock-out" the user during some operations (specifically, making network calls, and changing state quickly would queue up a ton of network calls that would quickly get in the way of each other).

Do I need to manage this manually with AppKit? I.e. put up a progress bar, and disable all UI Elements by hand?


回答1:


On the desktop you really don't want to do such a thing. It only works on the iPhone because there is nothing else a user might reasonably want to do with your app at the time. On the desktop there are possibilities for multiple windows etc. and anytime your app is unresponsive is considered a bug.

So more directly: No, there is nothing like this. You have to achieve the same effect with a sheet/modal panel, but most of the time should design the UI such that it's not a problem anyhow.



来源:https://stackoverflow.com/questions/1697029/ignoring-ui-events-in-appkit

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!