advertisement

Article:
  Animating Graphics in Cocoa, Part 1
Subject:   Using scrolling in NSView
Date:   2002-01-05 03:35:48
From:   zeus
Hi everyone,
I'm sorry to repost this topic here, but I hope it will give it more visibility, and since we are still speaking about graphics it isn't absolutely in the wrong place.
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


1 to 1 of 1
  1. Using scrolling in NSView
    2002-01-06 13:03:33  michele [View]

    • Using scrolling in NSView
      2002-01-09 12:40:59  zeus [View]

      • Using scrolling in NSView
        2002-01-10 13:42:51  michele [View]

        • Using scrolling in NSView
          2002-01-11 08:44:34  zeus [View]

1 to 1 of 1