Re: Bug? Not receiving mouseEntered and mouseExited events
Re: Bug? Not receiving mouseEntered and mouseExited events
- Subject: Re: Bug? Not receiving mouseEntered and mouseExited events
- From: Volker Runkel <email@hidden>
- Date: Tue, 17 Jan 2006 16:40:53 +0100
Hi,
I implemented a trackingRect to get mouseEntered, mouseExited and
mouseMoved events. The following code is copy/pasted from one of my
Apps code, so please ignore calls to views that only exist in my
application and replace them appropriate.
Volker
- (void) resetCursorRects
{
[super resetCursorRects];
//if (![self isHidden]) [self addCursorRect: [[self contentView]
frame] cursor: [NSCursor crosshairCursor]];
if (![self isHidden]) [self addCursorRect: toolTipRect cursor:
[NSCursor crosshairCursor]];
}
- (void)viewDidMoveToWindow
{
if (![self isHidden]) {
//trackingRect = [self addTrackingRect:[[self contentView] frame]
owner:self userData:nil assumeInside:NO];
trackingRect = [self addTrackingRect:toolTipRect owner:self
userData:nil assumeInside:NO];
[super viewDidMoveToWindow];
}
}
- (void)mouseEntered:(NSEvent *)event {
[ [self window] setAcceptsMouseMovedEvents:YES];
[ [self window] makeFirstResponder:scrollContentView];
}
- (void)mouseExited:(NSEvent *)theEvent {
[[self window] setAcceptsMouseMovedEvents:NO];
[ToolTip release];
}
- (void)mouseMoved:(NSEvent *)event {
//if ([self mouse:[self convertPoint:[event locationInWindow]
fromView:[[self window] contentView]] inRect:[[self contentView]
frame]]) {
if ([self mouse:[self convertPoint:[event locationInWindow] fromView:
[[self window] contentView]] inRect:toolTipRect]) {
NSPoint objectOrigin;
objectOrigin = [scrollContentView convertPoint:[event
locationInWindow] fromView:[[self window] contentView]];
[ToolTip
setString: [NSString stringWithFormat:@"%.2f ms %.2f
kHz", objectOrigin.x*(maxXAxis / [scrollContentView
frame].size.width), (objectOrigin.y-20) * ( maxYAxis /
(toolTipRect.size.height))]
forEvent: event];
}
}
Attachment:
smime.p7s
Description: S/MIME cryptographic signature
_______________________________________________
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