isMousePoint(_:in:)
Returns whether a region of the view contains a specified point, accounting for whether the view is flipped or not.
Declaration
func isMousePoint(_ point: NSPoint, in rect: NSRect) -> BoolParameters
- point:
A point that is expressed in the view’s coordinate system. This point generally represents the hot spot of the mouse cursor.
- rect:
A rectangle that is expressed in the view’s coordinate system.
Return Value
Discussion
Point-in-rectangle functions generally assume that the bottom edge of a rectangle is outside of the rectangle boundaries, while the upper edge is inside the boundaries. This method views aRect from the point of view of the user—that is, this method always treats the bottom edge of the rectangle as the one closest to the bottom edge of the user’s screen. By making this adjustment, this function ensures consistent mouse-detection behavior from the user’s perspective.
Never use the Foundation’s NSPointInRect(_:_:) function as a substitute for this method. It doesn’t account for flipped coordinate systems.