• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: problem with addTrackingRectangle
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: problem with addTrackingRectangle


  • Subject: Re: problem with addTrackingRectangle
  • From: Ricky Sharp <email@hidden>
  • Date: Wed, 15 Feb 2006 17:06:58 -0600


On Feb 15, 2006, at 9:22 AM, Ivan Kourtev wrote:

I am having a problem adding a tracking rectangle to a custom view -- I've overridden - resetCursorRects, and I am sending [self addTrackingRect:...] while in resetCursorRects. But I think the problem is that my custom view never actually receives any resetCursorRects messages (I checked and know this for a fact).

I also overrode -invalidateCursorRectsForView: in my custom window class containing the custom view. I verified that the window receives invalidateCursorRectsForView messages just fine. Then why doesn't resetCursorRects get sent to my custom view?

Do want tracking rects or cursor rects?

If it's tracking rects, this is what I do in all my custom views...

@interface MyView : NSView
{
@private
    NSTrackingRectTag trackingRectTag;
}
@end

@implementation MyView

- (void)viewWillMoveToWindow:(NSWindow*)aWindow
{
    if (trackingRectTag)
        {
        [self removeTrackingRect:trackingRectTag];
        trackingRectTag = 0;
        }
}

- (void)viewDidMoveToWindow
{
NSWindow* theWindow = [self window];

if (theWindow != nil)
{
NSPoint theMouseLocation = [theWindow mouseLocationOutsideOfEventStream];
NSRect theBounds = [self bounds];
BOOL theAssumeInsideFlag = NSMouseInRect ([self convertPoint:theMouseLocation fromView:nil],
theBounds, YES);

trackingRectTag = [self addTrackingRect:theBounds owner:self
userData:nil assumeInside:theAssumeInsideFlag];
}
}


- (void)mouseEntered:(NSEvent*)anEvent
{
    // Do work here
}

- (void)mouseExited:(NSEvent*)anEvent
{
    // Do work here
}
@end


For views that need cursor rects, I just implement resetCursorRects. For example, from a NSControl subclass:


- (void)resetCursorRects
{
if ([self isEnabled])
[self addCursorRect:[self bounds] cursor:[IIImageFactory pointingCursor_II]];
else
[self addCursorRect:[self bounds] cursor:[IIImageFactory normalCursor_II]];
}


where pointingCursor_II and normalCursor_II are class methods that return a singleton NSCursor.

___________________________________________________________
Ricky A. Sharp         mailto:email@hidden
Instant Interactive(tm)   http://www.instantinteractive.com

_______________________________________________
Do not post admin requests to the list. They will be ignored.
Cocoa-dev mailing list      (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden


References: 
 >problem with addTrackingRectangle (From: Ivan Kourtev <email@hidden>)

  • Prev by Date: Re: Strange file system behavior
  • Next by Date: Re: File System changes notifications
  • Previous by thread: Re: problem with addTrackingRectangle
  • Next by thread: File System changes notifications
  • Index(es):
    • Date
    • Thread