On Feb 18, 2010, at 8:44 PM, Mazen M. Abdel-Rahman wrote:

I was wondering if there is a straight forward away to know if the mouse is on the border of a view? I know how to detect if the mouse enters a view area by using NSTrackingArea - but how can I tell if the mouse is on a border? I would like to replicate iCal's behavior where a user can modify an event on the calendar by clicking on the edge of the appt. rectangle and dragging it.

Assuming you just care when the mouse clicks, you could test for it like this.

- (void) mouseDown:(NSEvent*)theEvent
{
NSPoint localMouseLocation = [self convertPoint:[theEvent locationInWindow] fromView:nil];
        NSRect  nonBorderRect = NSInsetRect([self bounds], 4, 4);

        if (NSPointInRect(localMouseLocation, nonBorderRect))
        {
                // click inside the non-border portion of the view
        }
        else
        {
                // click in the view's border
        }
}

_______________________________________________

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com

Reply via email to