Toolbar items do not reactivate

Hello, another annoying thing:

I use mainWindow’s makeKeyAndOrderFront_(me) to show a window and mainWindow’s orderOut_(me) to hide it (me is the current application). Sometimes everything is OK, but sometimes my toolbar items remain inactive. What’s wrong with them?


Well. after investigations, I didn’t find what’s wrong.

One handler calls mainWindow’s orderOut_(me), another handler calls makeKeyAndOrderFront_(me). There is no other point of the program that makes these calls.

Sometimes the window reappears with toolbar items deactivated. All other functions work fine. I don’t understand, it it a problem of responder? “make key” should fix that. So why does it work sometimes and sometimes not?

So, I found.

What do you do when the main window is closed after an alert as sheet is issued ?

If you rely on the alert’s answer to close the window, then you close the window as the sheet is visible!

It should not be a problem to dismiss a sheet from an ordered-out window. but it is. When the window reappears, the toolbar is not reactivated.

Do I have to raise a flag, like a “the-window-should-close-right-after-this-sheet-is-dismissed-and-the-handler-exited”?
Could be fixed in the eventLoop but. I don’t have one anymore.:confused:

I shall just avoid to say what I think of this Cocoa sophisticated mechanism to send alerts, intercept the answer elsewhere, dismiss the window here, take the appropriate action there.

Maybe I just post an alert:


Misery loves company :

This info from Apple :

This kind of problem where sometimes it works and sometimes not, is very difficult to diagnose without having access to the whole project. If you have some sample code that shows this problem, you should post it.