On 25.08.2016 at 17:21 Ken Thomases wrote:

> 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.

Tested it, the window is clearly main and key, this is the debug output:

CHECK: 0x10040b4d0 0x10040b4d0 0x10040b4d0

i.e. [NSApp mainWindow], [NSApp keyWindow] and my NSWindow pointer are
exactly the same before runModalForWindow() is 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?

Tried it, but unfortunately, this doesn't change anything.

I'm attaching the modified minimal demo program for reference.

-- 
Best regards,
 Andreas Falkenhahn                            mailto:andr...@falkenhahn.com

Attachment: main.m
Description: Binary data

_______________________________________________

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