> On 23 Aug 2016, at 1:46 AM, Andreas Falkenhahn <andr...@falkenhahn.com> wrote:
> 
> It is unusual in the way that it's not calling NSApplicationMain() but tries
> to imitate what NSApplicationMain() does. Here goes the code that is executed
> to set up the NSApp:


There’s your problem.

You’re not running a proper NSRunLoop, so the alert panel is going to be 
non-operational. When a modal alert is shown, the run loop is set to a run mode 
that reflects this, which changes the way events are routed and processed. 
Modal panels are really an illusion that the application creates by managing 
its NSRunLoop in this way.

You are going to have to fix your architecture to run the app in a far more 
conventional way.

I know what you said about a cross-platform model forcing your hand, but I 
don’t believe that your solution is the right one. I believe you can run the 
app in a standard way and still support this model. I know this because I had 
to do exactly the same thing when Mac OS X first came out, to adapt my app 
framework for the classic Mac OS (“MacZoop”) to run on OS X. That framework had 
a WaitNextEvent() style architecture, but with care I was able to adapt it to 
the modern approach without breaking that model, but still being something that 
played nice with preemptive mutitasking, non-centralized event despatch, and so 
on. Of course that was 15 years ago, and the details are now hazy, but the 
essence of it was to turn the thinking about fetching events on its head: 
WaitNextEvent is not something you poll, but something that goes to sleep until 
there’s something for your app to do. From the client’s perspective, there’s no 
difference!

I suggest you reinstate a standard runloop within NSApplication, stop playing 
games with it, and simply use its -nextEventMacthingMask: method to stand in 
for WaitNextEvent(). All your various problems will be solved at once.

Or use Carbon, not Cocoa, but good luck with that.

—Graham






_______________________________________________

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com

Reply via email to