spend X hours on this. test *** combinations.
I have mac OS app without storyboard.
I also have menu status bar.
I click on the manu status bar to hide/unhide my app.
- (void) menuBarControllerStatusChanged: (BOOL) active {
if([[NSApplication sharedApplication] isHidden])
{
NSImage *image = [UIImage imageNamed:@"newsFeedsAlertOFF"];
self.mainStatusBar.image = image;
NSAssert(self.windowController!=nil, @"window controll is nil");
NSAssert(self.windowController.window!=nil, @"window is nil");
[[NSApplication sharedApplication] unhide:self];
[self.windowController.window makeKeyAndOrderFront:self];
[[NSApplication sharedApplication] activateIgnoringOtherApps:YES];
}
else
{
[NSApplication sharedApplication] hide:self];
[[NSApplication sharedApplication] deactivate];
}
}
The problem :
on unhide, the app is visible and active (focused) BUT the NSWindow 3 button are gray color.
ONLY if I active another app (safari for example) and return to my app, then the NSWindow 3 buttons are display with color.
In what situation the NSWindow is active and the 3 buttons are gray ? If there is no "normal" situation, maybe I need to report bug ?
attention 1 : I don't use storyboard. everthing is created by code (EXCEPT the MainMenu.xib)
attention 2 : this was tested on Mojave and Catalina .
attention3 : the 3 buttons are flickering for 0.1 seconds with their color and then turn gray.(with this sample code, but not in all code combinations I tested)
Thanks in adavnce.
Found the problem :
-(BOOL)applicationShouldTerminateAfterLastWindowClosed:(NSApplication *)sender
{
return YES;
}
when I disable this,
I could hide/unhide the my app and activate it correctly with 3 buttons of window with their colors.
Another thing import was :
[self.windowController.window orderOut:nil];
I wish AppKit and xcode were more developer friendly.