• 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
mouseExited: acts very unreliably?
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

mouseExited: acts very unreliably?


  • Subject: mouseExited: acts very unreliably?
  • From: Keith Blount <email@hidden>
  • Date: Sat, 8 Jan 2005 04:41:59 -0800 (PST)
  • Comment: DomainKeys? See http://antispam.yahoo.com/domainkeys

Hello,

I am using tracking rects with a view in order to
highlight it when the mouse is inside it, but I am
getting some very unreliable results with mouseExited:
and cannot work out. mouseEntered: seems to work fine,
but I am frequently left with views that are
highlighted even though the mouse has left them.

To give a bit more info: I have a custom view
contained inside a scroll view. This custom view
comprises a text view and another custom view which
acts as a margin. Clicking into this margin creates
another view (a note card) which is added as a subview
of the margin view. It is this note subview that
should receive mouseEntered: and mouseExited:
notifications so that it  can highlight itself. So the
view hierarchy is like this:

-* scroll view
---* text view
---* margin view
-----* a note (should highlight only on mouse over
-----* another note
-----* etc

I am finding it very difficult to track down this bug,
as it seems completely random... If anyone can give me
any pointers on where I might be going wrong, I would
be very grateful.

Here is my code:

// METHODS TO DEAL WITH HIGHLIGHTING ON MOUSE OVER
- (void)resetTrackingRect
{
	// Clear out the old tracking rect
	[self clearTrackingRect];

	// Create a new tracking rect
	rolloverTrackingRectTag = [self addTrackingRect:[self
visibleRect]
											  owner:self
										   userData:NULL
									   assumeInside:NO];
}

- (void)clearTrackingRect
{
	// If we have a tracking rect, then remove it
	if (rolloverTrackingRectTag > 0)
	{
		[self removeTrackingRect:rolloverTrackingRectTag];
		rolloverTrackingRectTag = 0;
	}
}

// This is called automatically after a view is moved,
resized or scrolled
- (void)resetCursorRects
{
	[super resetCursorRects];
	[self resetTrackingRect];
}

// Override removeFromSuperview to remove the tracking
rect
- (void)removeFromSuperview
{
	[self clearTrackingRect];
	[super removeFromSuperview];
}

// Highlight on mouse over
- (void)mouseEntered:(NSEvent *)event
{
	// Post a notification that informs the associated
text view that it needs to draw attachment lines
	[[NSNotificationCenter defaultCenter]
postNotificationName:HEMMarginCardShouldDrawIndexLineNotification
														object:self];

	[self setHighlighted:YES];;
	[self setNeedsDisplay:YES];
	[[self superview] setNeedsDisplay:YES];
}

// End highlight on mouse exit
- (void)mouseExited:(NSEvent *)event
{
	// Post a notification that informs the associated
text view that it no longer needs to draw attachment
lines
	[[NSNotificationCenter defaultCenter]
postNotificationName:HEMMarginCardShouldHideIndexLineNotification
														object:self];
	[self setHighlighted:NO];
	[self setNeedsDisplay:YES];
	[[self superview] setNeedsDisplay:YES];
}

Many thanks in advance,
Keith



__________________________________
Do you Yahoo!?
All your favorites on one personal page – Try My Yahoo!
http://my.yahoo.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

  • Prev by Date: Re: NSTask with non-ASCII paths
  • Next by Date: Custom Find Panel
  • Previous by thread: periodic events
  • Next by thread: Re: mouseExited: acts very unreliably?
  • Index(es):
    • Date
    • Thread