displaying window on activation
displaying window on activation
- Subject: displaying window on activation
- From: Chuck Soper <email@hidden>
- Date: Fri, 1 Oct 2004 12:43:21 -0700
Hello,
I'm trying to figure out how to make a window key and ordered front
when receiving a NSApplicationDidBecomeActiveNotification (kind of
like the BBEdit8 demo in functionality). The window is a demo dialog
instantiated from an NSWindowController in its own nib.
- If I activate my app by clicking on one of its app windows then my
demo dialog is not active (that is, the title indicates an inactive
window and the default button is disabled) until I click on the
window.
- If I activate my app by clicking on its icon in the dock or by
command tabbing into it then everything works fine.
When my app receives NSApplicationDidBecomeActiveNotification, I call
the following code (if a certain amount of time has passed):
demoController = [[DemoController alloc] initWithWindowNibName:@"Demo"];
NSWindow * demoWindow = [demoController window];
[demoWindow setInitialFirstResponder:[demoWindow contentView]];
[demoWindow center];
[demoWindow makeKeyAndOrderFront:nil];
[demoController showWindow:nil];
NSWindow * mainWindow = [NSApp mainWindow];
if (mainWindow != nil) {
int windowNumber = [demoWindow windowNumber];
[mainWindow orderWindow:NSWindowBelow relativeTo:windowNumber];
}
[NSApp runModalForWindow:demoWindow];
When the user dismisses the window, I send '[self autorelease]' from
within the nib's controller (file owner). Allocating and deallocating
the nib every time it's displayed did solve some activation problems.
When I get this working, I'll try not to alloc/dealloc for each
display of the window.
I've searched the archives and discovered a number of threads with
similar problems without clear solutions. Does anyone have any ideas?
Thanks,
Chuck
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Cocoa-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden