windowWillMove
WindowWillMove refers to a delegate hook in macOS AppKit, used with NSWindowDelegate. It is a callback that notifies the window’s delegate when the window is about to move, typically as the user drags the window by its title bar. The method is implemented as windowWillMove: and receives an NSNotification whose object is the NSWindow that will move. The delegate can observe the impending movement or inspect the window’s frame before the move occurs, which can be useful for coordinating UI or enforcing layout constraints.
- It is informational rather than prescriptive; implementing windowWillMove: does not prevent the window from moving. The
- The notification’s object is the window being moved. Depending on the OS version, the notification’s userInfo
- A related event is the NSWindowWillMoveNotification, which is posted to the default notification center when a
- Implement windowWillMove: in the window’s delegate to monitor movement and possibly update other UI in response.
- Access the window via notification.object and examine its frame if needed for contextual adjustments.
- Use windowDidMove: to respond after movement has completed if post-move actions are required.
See also: windowDidMove, NSWindowWillMoveNotification, NSWindowDelegate.