Re: mouseExited: acts very unreliably?
Re: mouseExited: acts very unreliably?
- Subject: Re: mouseExited: acts very unreliably?
- From: Keith Blount <email@hidden>
- Date: Sat, 8 Jan 2005 08:38:38 -0800 (PST)
- Comment: DomainKeys? See http://antispam.yahoo.com/domainkeys
Many thanks for your reply, much appreciated. I'll
look up the "frame each view" debugging variable, as
it sounds useful and is something I've never used. I
have managed to track the root of my problem, though
(I think), and it is to do with the nature of the way
my views work. Although I doubt it is of much interest
to you personally, I hope you don't mind me putting
how I got around it here just for the sake of the
archives (feel free to skip the rest :) ):
My note views in the margin are attached to text in
the text view by tracking the place of the character
at a given index. Thus, if the user places the mouse
inside a note view, and then starts typing in the text
view somewhere above the text that is attached to that
note view, that note view will get moved down (using
setFrame:). So, the view is set to highlighted but may
be moved down so that the mouse is no longer in it -
so of course, it does not receive a mouse exited
message and stays highlighted. What I needed to do
was, whenever setting the frame, check to see if the
mouse is still inside the view. I used this code to do
this:
// If for some reason the mouse is no longer inside
the card (eg. if the card was highlighted and the user
// typed a chunk of text in the text view above it),
make sure we are no longer highlighted
NSPoint mousePoint = [self convertPoint:[[self window]
mouseLocationOutsideOfEventStream] fromView:nil];
if (![self mouse:mousePoint inRect:[self bounds]])
{
[self setHighlighted:NO];
[[NSNotificationCenter defaultCenter]
postNotificationName:HEMMarginCardShouldHideIndexLineNotification
object:self];
}
else if (!isHighlighted) // the view has moved and now
the mouse is over it
{
[self setHighlighted:YES];
[[NSNotificationCenter defaultCenter]
postNotificationName:HEMMarginCardShouldDrawIndexLineNotification
object:self];
}
At first I put the above code in an override of
setFrame:, but this only made things worse -
presumably because it was too late - but now that I
have put it into my resetTrackingRect: method, initial
tests indicate that everything is working fine (I
hope).
Many thanks again for the help,
Keith
--- email@hidden wrote:
>
> On Jan 8, 2005, at 6:41 AM, Keith Blount wrote:
>
> > 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.
> >
>
> This does sound like a symptom of overlapping
> tracking rects/views -
> are you absolutely sure that each view is
> independant of each other?
> (Perhaps add a frame on the rect in your view's
> drawing routine, or
> using the magic "frame each view" debugging
> environment variable).
>
>
> Glenn Andreas
> email@hidden
> <http://www.gandreas.com/> oh my!
> Mad, Bad, and Dangerous to Know
>
>
__________________________________________________
Do You Yahoo!?
Tired of spam? Yahoo! Mail has the best spam protection around
http://mail.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