Hi
ViewControllers events are easy to catch just open its file and well see viewdid load and other stuff, but how to catch windows based
events such as when window get resized or minimized ? and in which file well find them ?
--
Kindest Regards
I finally made it work but had to turn around something that looks like an XCode bug or OSX bug…
I changed to:
import Cocoa
class S1W2WC: NSWindowController, NSWindowDelegate {
override func windowDidLoad() {
super.windowDidLoad()
// Implement this method to handle any initialization after your window controller's window has been loaded from its nib file.
}
func windowDidMove (_ notification: Notification) { // Take care of space after underscore
let newOrigin = self.window!.frame.origin
print("Window Did Move:", newOrigin)
}
func windowDidResize (_ notification: Notification) {
let newSize = self.window!.frame.size
print("Window Did Resize:", newSize)
}
}
and
import Cocoa
class SecondVC: NSViewController {
var parentWindowController: NSWindowController? // Helps keeping a reference to the controller
override func viewDidLoad() {
super.viewDidLoad()
// Do view setup here.
}
override func viewDidAppear() {
super.viewDidAppear()
parentWindowController = self.view.window!.windowController // This is needed, otherwise dnotification does not go through
self.view.window!.delegate = parentWindowController as! S1W2WC
}
}
For reference on the notification issue: