0

I have a class called mapWindow which is hooked up to a window in IB.

No matter what, the red circle which I want the program to render won't show up unless the code is under drawRect or I move the window borders. Not even unlocking and locking the focus updates the window.

theOtherWindowView is actually a NSView hooked up to a custom view in IB.

- (void)test
{
    [theOtherWindowView lockFocus];
    NSBezierPath *path = [NSBezierPath bezierPath];
    NSPoint center = [self drawPoint];
    [path moveToPoint: center];
    [path appendBezierPathWithArcWithCenter:center
                                        radius:explosionRadius
                                    startAngle:0
                                    endAngle:360];
    [[NSColor redColor] set];
    [path fill];

    [theOtherWindowView unlockFocus];
}

I don't want to use drawRect because I want multiple instances not one shape that has it's coordinates changed every update.

I've also tried [self lockFocus] and [mapWindow lockFous]

evdude100
  • 437
  • 4
  • 18

1 Answers1

2

Keep doing your drawing in -drawRect:. When -drawRect: is sent, your view's coordinate system and clipping boundaries will have been set up for you, and your window's drawing context will be the current one.

In that method, draw as many of these circles as you want.

NSResponder
  • 16,861
  • 7
  • 32
  • 46
  • No, beacause drawrect can only be called via setNeedsDisplay:YES which allows one object not multiple copies. – evdude100 Jun 30 '11 at 11:46
  • @evdude100, do you see how you could draw multiple paths in the same call to `drawRect:`? – alltom Jul 02 '11 at 19:26
  • Yes, but I want my button click to define a point for the shape (done) but create the shape at every point I define – evdude100 Jul 02 '11 at 22:35