Accessory NSPanel vanishes on first click after app launches
Accessory NSPanel vanishes on first click after app launches
- Subject: Accessory NSPanel vanishes on first click after app launches
- From: Peter <email@hidden>
- Date: Tue, 02 Aug 2011 20:58:54 +0200
Developing for OS 10.5 and 10.6 I have an application with a main window (no documents window) and a (non-modal) accessory NSPanel I want to show only when the main window is the key window. I want the NSPanel hidden, however, when the preferences or about window comes up or when the app is in the background. The panel never is only for use with the mouse and does not have to become key window.
I implemented this using the following delegate methods for the main window:
- (void)windowDidBecomeKey:(NSNotification *)notification
{
if ([notification object] == mainWindow) {
[editPanel orderFront:self];
}
}
- (void)windowDidResignKey:(NSNotification *)notification
{
if ([notification object] == mainWindow) {
[editPanel orderOut:self];
}
}
Everything works as intended - except immediately after the applications launches:
The main window is shown, and floating above it the panel, as intended.
When I click on the the panel for the first time, however, the panel vanishes from the screen.
After I deactivate and activate the window again (e.g. by showing the preferences window etc.) the panel is shown again and from then on works absolutely normally: When the main window is key, the panel is shown and accepts mouse clicks, and it is hidden when the main window resigns key. (Both the panel and the main window are instantiated in the nib. Turning visible at launch on or off does not seem to have an influence. I am not using any bindings for both windows in question. None of the windows in question use dedicated window controllers.)
I am puzzled and I don't have a clue how to debug this. The debugger log shows nothing.
I experimented with
[mainWindow addChildWindow:editPanel ordered:NSWindowAbove];
and
[mainWindow removeChildWindow:editPanel];
but did not manage to achieve the desired effect.
Thanks for any insight or pointers to relevant documentation.
Peter_______________________________________________
Cocoa-dev mailing list (email@hidden)
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:
This email sent to email@hidden