Home > Software engineering >  Make "Close All" (cmd option W) apply only to one type of document windows
Make "Close All" (cmd option W) apply only to one type of document windows

Time:08-30

I have an application that manages different types of NSDocument subclasses (along with matching NSWindow subclasses).

For instance, it's possible that the app has one window of type A open, and two windows of type B.

Now, if a window of type B is active, and the user chooses "Close All" or hits cmd option W, all my app's windows are sent the close event.

But I only want all of the active window type's windows closed instead, i.e. only the two type B, not the type A window. How do I best accomplish this?

I currently have no explict menu entry for "Close All". Instead, macOS provides that automagically. If there perhaps a way to intercept a "closeAll" event? Can't find one, though.

CodePudding user response:

You might succeed with overriding your document's Menu item in IB

  • Related