Function

NSMouseInRect(_:_:_:)

Returns a Boolean value that indicates whether the point is in the specified rectangle.

Declaration

func NSMouseInRect(_ aPoint: NSPoint, _ aRect: NSRect, _ flipped: Bool) -> Bool

Return Value

true if the hot spot of the cursor lies inside a given rectangle, otherwise false.

Discussion

This method assumes an unscaled and unrotated coordinate system. Specify true for flipped if the underlying view uses a flipped coordinate system.

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.

See Also

Managing Rectangles

func NSContainsRect(NSRect, NSRect) -> Bool

Returns a Boolean value that indicates whether one rectangle completely encloses another.

func NSEqualRects(NSRect, NSRect) -> Bool

Returns a Boolean value that indicates whether the two rectangles are equal.

func NSIsEmptyRect(NSRect) -> Bool

Returns a Boolean value that indicates whether a given rectangle is empty.

func NSHeight(NSRect) -> CGFloat

Returns the height of a given rectangle.

func NSInsetRect(NSRect, CGFloat, CGFloat) -> NSRect

Insets a rectangle by a specified amount.

func NSIntegralRect(NSRect) -> NSRect

Adjusts the sides of a rectangle to integer values.

func NSIntegralRectWithOptions(NSRect, AlignmentOptions) -> NSRect

Adjusts the sides of a rectangle to integral values using the specified options.

func NSIntersectionRect(NSRect, NSRect) -> NSRect

Calculates the intersection of two rectangles.

func NSIntersectsRect(NSRect, NSRect) -> Bool

Returns a Boolean value that indicates whether two rectangles intersect.

func NSMakeRect(CGFloat, CGFloat, CGFloat, CGFloat) -> NSRect

Creates a new NSRect from the specified values.

func NSMaxX(NSRect) -> CGFloat

Returns the largest x coordinate of a given rectangle.

func NSMaxY(NSRect) -> CGFloat

Returns the largest y coordinate of a given rectangle.

func NSMidX(NSRect) -> CGFloat

Returns the x coordinate of a given rectangle’s midpoint.

func NSMidY(NSRect) -> CGFloat

Returns the y coordinate of a given rectangle’s midpoint.

func NSMinX(NSRect) -> CGFloat

Returns the smallest x coordinate of a given rectangle.

func NSMinY(NSRect) -> CGFloat

Returns the smallest y coordinate of a given rectangle.

func NSOffsetRect(NSRect, CGFloat, CGFloat) -> NSRect

Offsets the rectangle by the specified amount.

func NSPointInRect(NSPoint, NSRect) -> Bool

Returns a Boolean value that indicates whether a given point is in a given rectangle.

func NSRectFromString(String) -> NSRect

Returns a rectangle from a text-based representation.

func NSStringFromRect(NSRect) -> String

Returns a string representation of a rectangle.

func NSRectFromCGRect(CGRect) -> NSRect

Returns an NSRect typecast from a CGRect.

func NSRectToCGRect(NSRect) -> CGRect

Returns a CGRect typecast from an NSRect.

func NSUnionRect(NSRect, NSRect) -> NSRect

Calculates the union of two rectangles.

func NSWidth(NSRect) -> CGFloat

Returns the width of the specified rectangle.