Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

window buttons are greyed when unhide and active the app from status bar

enter image description here My app has NSStatusBarButton on status bar (where the time, wifi etc) The user can tap to show/hide the app.

to hide :

[[NSApplication sharedApplication] hide:self];
[[NSApplication sharedApplication] deactivate];

to show :

[self.windowController.window makeKeyAndOrderFront:self];
[[NSApplication sharedApplication] activateIgnoringOtherApps:YES];

The problem is when I show the app, the window buttons (close, maximise ) are flickering their colour, then turn gray. I can see in logs of events the application is active and it responds to mouse scroll.

Only if I activate OTHER app with the mouse and return back to my app, the buttons will be active with there colour (red and green)

More info :
1. the app is created in code (not storyboard) besided the mainMenu.xib.
2. when I tap the image menu status bar to UNHIDE the app, in debug mode=on, the code is break with this error :

"error: Execution was interrupted, reason: EXC_BAD_ACCESS (code=1, address=0x4e47432b2b00). The process has been returned to the state before expression evaluation."

Any ideas where to continue from here ?

like image 586
user1105951 Avatar asked Nov 18 '25 02:11

user1105951


1 Answers

Thanks to the help of Asperi, the create sample code to narrow the diffrences, the problem was enabling this override :

-(BOOL)applicationShouldTerminateAfterLastWindowClosed:(NSApplication *)sender
{
    return YES;
}
  1. disable it and I could unhide/hide the app with the 3 buttons being activated with their color.

  2. also this [window orderOut] was important call.

like image 123
user1105951 Avatar answered Nov 19 '25 16:11

user1105951



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!