开发者

Ignoring UI Events in AppKit

开发者 https://www.devze.com 2022-12-11 01:01 出处:网络
If I wanted to ignore a touch event in UIKit on the iPhone I would simply do: // Begin ignoring events

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 durin开发者_开发技巧g 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?


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.

0

精彩评论

暂无评论...
验证码 换一张
取 消