Re: How to detect if mouse on border of view
Re: How to detect if mouse on border of view
- Subject: Re: How to detect if mouse on border of view
- From: Quincey Morris <email@hidden>
- Date: Fri, 19 Feb 2010 14:58:09 -0800
On Feb 19, 2010, at 13:36, Mazen M. Abdel-Rahman wrote:
> Thanks everyone for your help on this. I wanted to know if the mouse was on the border area prior to the mouse down event to determine if the mouse icon should change as the mouse hovers over the border. Is there a way to do this without a mouseMoved event?
I think the easiest way to do this is to use two NSTrackingAreas, one inset inside the other. When the mouse is inside the larger one but outside the smaller one, the mouse is in the "border". You could use mouseEntered:/mouseExited: to determine the state, and cursorUpdate: to set the mouse cursor appropriately.
However, I think this border behavior has another, trickier UI aspect. The "border" that the user can drag really needs to extend beyond the apparent rectangle. That is, if I'm try to "grab" what appears to be the border, it should be OK if I'm a couple of pixels outside it or a couple of pixels inside it. This means a bit more work for you, because you'll have to do something like one of these:
1. Make your actual view frame slightly larger than you need for drawing, so that the actual grab-able border is literally within the view.
2. Use the natural view frame, but embed your view inside a slightly larger view that represents the outside edge of the border.
3. Detect the mouse position (relative to the "border") at a higher level in the view hierarchy, so that you're not restricted by the actual frame of the view being resized.
4. Avoid using a view for each of the iCal-like-event elements, but simply draw them as graphic elements within a larger view that represents the calendar. (When there can possibly be many graphic elements, making each one a separate view is not necessarily the best choice.)
_______________________________________________
Cocoa-dev mailing list (email@hidden)
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:
This email sent to email@hidden