Instance Method

mouse:inRect:

Returns whether a region of the view contains a specified point, accounting for whether the view is flipped or not.

Declaration

- (BOOL)mouse:(NSPoint)point inRect:(NSRect)rect;

Parameters

aPoint

A point that is expressed in the view's coordinate system. This point generally represents the hot spot of the mouse cursor.

aRect

A rectangle that is expressed in the view’s coordinate system.

Return Value

YES if aRect contains aPoint, NO otherwise.

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.

See Also

Event Handling

- acceptsFirstMouse:

Overridden by subclasses to return YES if the view should be sent a mouseDown: message for an initial mouse-down event, NO if not.

- hitTest:

Returns the farthest descendant of the view in the view hierarchy (including itself) that contains a specified point, or nil if that point lies completely outside the view.

- performKeyEquivalent:

Implemented by subclasses to respond to key equivalents (also known as keyboard shortcuts).

- rightMouseDown:

Informs the view that the user has pressed the right mouse button.

mouseDownCanMoveWindow

A Boolean value indicating whether the view can pass mouse down events through to its superviews.

inputContext

The text input context object for the view.