confinementRect(for:on:)
Invoked to allow the delegate to specify a display location for the menu.
Declaration
@MainActor optional func confinementRect(for menu: NSMenu, on screen: NSScreen?) -> NSRectParameters
- menu:
The menu object.
- screen:
The screen the menu will open on.
Return Value
The rectangle the menu should be displayed within, in screen coordinates.
Discussion
This method is sent to the delegate when a menu is about to be opened on the specified screen.
If you return NSZeroRect, or if the delegate doesn’t implement this method, the menu will be confined to the bounds appropriate for the given screen. The returned rect may not be honored in all cases, for example, if it would force the menu to be too small.