swift - Detect maximize/minimize window event and do it programmatically -


how detect minimize/maximize window , do programmatically. know need use nswindowdelegate, but:

class appdelegate: nsobject, nsapplicationdelegate, nswindowdelegate {     func windowwillminiaturize(_ notification: notification) {             print("1")         } } 

this not working. , how maximize/minimize programmatically have no idea.

enter image description here

it in apples documentation on nswindowdelegate: https://developer.apple.com/reference/appkit/nswindowdelegate

you can implement in class set delegate window:

func windowwillminiaturize(notification)  

tells delegate window minimized.

func windowdidminiaturize(notification) 

tells delegate window has been minimized.

func windowdiddeminiaturize(notification) 

tells delegate window has been deminimized.

nswindow has methods - find when visiting documentation: https://developer.apple.com/reference/appkit/nswindow

you can call anywhere on window:

func performminiaturize(any?) 

simulates user clicking minimize button momentarily highlighting button, minimizing window.

func miniaturize(any?) 

removes window screen list , displays minimized window in dock.

func deminiaturize(any?) 

de-minimizes window.


Comments

Popular posts from this blog

sql server - Cannot query correctly (MSSQL - PHP - JSON) -

php - trouble displaying mysqli database results in correct order -

C++ Linked List -