简体   繁体   中英

macOs Swift change minimize behavior?

I'm trying to override the behavior of the minimize button on my NSWindow in my Cocoa macOS application.

The same way that you can use the

func windowShouldClose(_ sender: NSWindow) -> Bool

function from NSWindowDelegate to override the Exit button's behavior, I'd like to be able to customize what happens when the Minimize button is tapped.

Instead of minimizing, I'd like to cancel the minimize event and execute my own custom code.

I have found windowWillMiniaturize(_ notification: Notification) and func windowDidMiniaturize(_ notification: Notification) , however these don't allow me to cancel the event and replace it with my own custom code (from what I can see).

子类NSWindow并重写miniaturize(_ sender: Any?)

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM