Re: mousedown in a view
Re: mousedown in a view
- Subject: Re: mousedown in a view
- From: glenn andreas <email@hidden>
- Date: Tue, 6 Sep 2005 21:52:24 -0500
On Sep 6, 2005, at 8:43 PM, Jeff Childers wrote:
the view appears to not be aligning with the tracking rect.
mouse x: 21.000000 y: 435.000000 height: 414.000000 width: 96.000000
mouse x: 21.000000 y: 23.000000 height: 414.000000 width: 96.000000
mouse x: 115.000000 y: 67.000000 height :414.000000 width: 96.000000
21 pixels hidden under left side
21 extra pixels on top edge of view and the tracking rect
29 pixels hidden on the right
23 pixels hidden on the bottom
when I draw in the view everything matches up
view size 96w 414h
- (void)mouseDown:(NSEvent *)theEvent
{
NSPoint loc = [theEvent locationInWindow];
loc.x -= [self frame].origin.x;
loc.y -= [self frame].origin.y;
NSLog(@"mouse x: %f y: %f height: %f width: %f", loc.x,loc.y,
[self frame].size.height,[self frame].size.width);
}
after some experimenting when I make subview of scrollview and set
the scrollers to small and horizonal off is when things become
misaligned
how can I fix this?
This is not how you should be converting from window based coordinate
to view base coordinate systems for many reasons (including handling
of scaling, flipping, and other transformations).
Use NSView's convertPoint:fromView: instead...
Glenn Andreas email@hidden
<http://www.gandreas.com/> wicked fun!
Widgetarium | the quickest path to widgets
_______________________________________________
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