I have an NSPanel window in my app that I want to toggle open and close with a button on the toolbar. This seems like a fairly basic operation, and indeed one I see in many apps (like Inspector views). However, I'm struggling to find the right way to do this.
I've looked at the performClose: and the makeKeyAndOrderFront: methods, but I can't work out how to make them work in my method. Basically, I want something like this
-(IBAction)togglePanel:(id)sender {
if ( ) //what do i put here to assess if _myPanel is already open?
// tell _myPanel to close
else {
//tell _myPanel to open
}
}
Answering my own question, here. But got what I wanted thus: