On Aug 25, 2016, at 6:51 AM, Andreas Falkenhahn <andr...@falkenhahn.com> wrote:
> 
> Isn't runModalForWindow() supposed to activate the window which formerly
> had the focus when it returns? It doesn't do this here. When 
> runModalForWindow()
> returns, the window that was active when I called runModalForWindow()
> isn't made active again. 
> 
> Of course, I could do this manually by calling makeKeyAndOrderFront()
> on that window after runModalForWindow() returns but I think that it
> would be much more natural if this task was handled by runModalForWindow().
> 
> Thus my question: Is this the normal behaviour of runModalForWindow()
> or am I doing something wrong here?
> 
> I first thought that this behaviour might be due to my custom application
> setup and event handling but it isn't. I can also reproduce the behaviour
> in a minimal example program. I'm attaching this minimal example program
> for reference. Granted, it doesn't call NSApplicationMain() but I think
> it is nevertheless a good OS X citizen because it does [NSApp run] and
> doesn't do any custom event handling.

Try logging [NSApp mainWindow] and [NSApp keyWindow] in your -buttonPresse: 
method.  I'm not sure that -makeKeyAndOrderFront: takes full effect before 
-[NSApplication run] has been called.

What if you move the -makeKeyAndOrderFront: call (and possibly the whole 
creation of the initial window) into the -applicationDidFinishLaunching: method 
of an app delegate?

Regards,
Ken


_______________________________________________

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