FROM : an0
DATE : Sat Apr 26 17:47:11 2008
> Does this sample application still use cursorRects/NSTrackingRects?
> Leopard introduced a new mechanism -- NSTrackingArea and cursorUpdate
> events -- which doesn't have some of the problems that the old
> mechanism supposedly had.
>
> With NSTrackingArea and cursorUpdate you should be able to get
> complete, consistent control of the cursor inside the visible portion
> of your view (even when returning from the outside), and it's fairly
> easy to use. [NSScrollView setDocumentCursor:] will still be necessary
> to control the part of the scroll view outside the visible portion of
> your view, and control entirely outside the scroll view (or window)
> will be harder to enforce, because other views (and other windows) may
> have their own ideas.
Thanks. I've tried NSTrackingArea, and it seems a clearer concept and
easier to use. However, there are still two problems I can't fix:
1. Setting cursor in initWithFrame: and awakeFromNib does not have
effect. So I can't set the initial cursor.
2. Setting cursor together with tracking areas renders the cursor
setting ineffective. I found this from my mouseUp action. With the
code handling tracking areas, [[NSCursor openHandCursor] set] did not
give me an openHandCursor, but an arrowCursor.
-(void)mouseUp:(NSEvent *)event
{
dragging=NO;
[self removeTrackingArea:trackingRect];
self.trackingRect = [[[NSTrackingArea alloc] initWithRect:[self
calculatedItemBounds]
options:NSTrackingCursorUpdate | NSTrackingActiveInActiveApp
owner:self
userInfo:nil] autorelease];
[self addTrackingArea:trackingRect];
[[NSCursor openHandCursor] set];
}
DATE : Sat Apr 26 17:47:11 2008
> Does this sample application still use cursorRects/NSTrackingRects?
> Leopard introduced a new mechanism -- NSTrackingArea and cursorUpdate
> events -- which doesn't have some of the problems that the old
> mechanism supposedly had.
>
> With NSTrackingArea and cursorUpdate you should be able to get
> complete, consistent control of the cursor inside the visible portion
> of your view (even when returning from the outside), and it's fairly
> easy to use. [NSScrollView setDocumentCursor:] will still be necessary
> to control the part of the scroll view outside the visible portion of
> your view, and control entirely outside the scroll view (or window)
> will be harder to enforce, because other views (and other windows) may
> have their own ideas.
Thanks. I've tried NSTrackingArea, and it seems a clearer concept and
easier to use. However, there are still two problems I can't fix:
1. Setting cursor in initWithFrame: and awakeFromNib does not have
effect. So I can't set the initial cursor.
2. Setting cursor together with tracking areas renders the cursor
setting ineffective. I found this from my mouseUp action. With the
code handling tracking areas, [[NSCursor openHandCursor] set] did not
give me an openHandCursor, but an arrowCursor.
-(void)mouseUp:(NSEvent *)event
{
dragging=NO;
[self removeTrackingArea:trackingRect];
self.trackingRect = [[[NSTrackingArea alloc] initWithRect:[self
calculatedItemBounds]
options:NSTrackingCursorUpdate | NSTrackingActiveInActiveApp
owner:self
userInfo:nil] autorelease];
[self addTrackingArea:trackingRect];
[[NSCursor openHandCursor] set];
}
| Related mails | Author | Date |
|---|---|---|
| Ling Wang | Apr 20, 12:43 | |
| Jens Alfke | Apr 20, 18:06 | |
| Quincey Morris | Apr 20, 18:37 | |
| Ling Wang | Apr 21, 15:22 | |
| Jens Alfke | Apr 21, 16:41 | |
| Mike Wright | Apr 21, 17:48 | |
| an0 | Apr 23, 17:10 | |
| Quincey Morris | Apr 24, 00:44 | |
| Scott Anguish | Apr 24, 07:36 | |
| an0 | Apr 26, 17:47 | |
| Quincey Morris | Apr 26, 21:48 | |
| an0 | Apr 27, 08:14 | |
| an0 | Apr 27, 11:35 |






Cocoa mail archive

