Using Scrolling in a subclass of NSView
Using Scrolling in a subclass of NSView
- Subject: Using Scrolling in a subclass of NSView
- From: Jérôme Paschoud <email@hidden>
- Date: Thu, 03 Jan 2002 18:06:47 +0100
Hi everyone,
I'm newbie to cocoa programming, and I try to generate a user interface for
a simple 2D grapher and in this soft I need to scroll my view. In fact I
have a subclass of NSView in wich i'm drawing my function (i.e y=x^2) and I
want to be able to click on one point of my NSView and get the new view
centered where i clicked. In order to get that I override the methode
mouseDown.
Here's the code:
-(void)mouseDown:(NSEvent *) theEvent{
NSPoint loc = [theEvent locationInWindow];
loc.x -= [self frame].origin.x;
loc.y -= [self frame].origin.y;
[self scrollPoint:loc];
[self setNeedsDisplay:YES];
}
That is working: I explain no error during compilation, no error when
running but nothing happened when I click. And the only thing i'm sure is
that i'm going into thi method because when I set a breakpoint to see if
there's a NSPoint loc create, I'm able to see it and the coordinates i get
seems to be ok.
Thanks to anyone who can help me.
Regards Jerome
--
Mac like the best, die like the rest.
Paschoud Jirtme
Student
Email:
Private->email@hidden
Profesional-> email@hidden
Phone: 022-774-27-31
Handy: 078-625-27-31