Mac OS Resize Button
Mac OS Resize Button
How to trigger a event when resize button is resize button
1 Answer
1
windowDidResize function
From the developer website, you can find this function declaration from NSWindowDelegate
:
NSWindowDelegate
optional func windowDidResize(_ notification: Notification)
Tells the delegate that the window has been resized.
So, for illustration sake (in Swift 4):
class YourViewController: NSViewController, NSWindowDelegate {
// constructors and other methods are omitted for illustration simplicity
func windowDidResize(_ notification: Notification) {
// You can listen to window resize event here
}
}
Other useful functions
Note that there is other sizing windows functions available:
func windowWillResize(NSWindow, to: NSSize) -> NSSize
Tells the delegate that the window is being resized (whether by the
user or through one of the setFrame... methods other than
setFrame(_:display:) ).
func windowWillStartLiveResize(Notification)
Tells the delegate that the window is about to be live resized.
func windowDidEndLiveResize(Notification)
Tells the delegate that a live resize operation on the window has
ended.
By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.
Comments
Post a Comment