Objective-C Drawing on a seprate window?

NSView s drawRect: method is called on your behalf; you should use it to your drawing, as described in Drawing View Content.

NSView's drawRect: method is called on your behalf; you should use it to your drawing, as described in Drawing View Content. @interface mapWindow : NSView { @private NSView* theMapWindow; NSPoint drawPoint; } // - (void)drawRect:(int)pointx: (int)pointy; @property (assign) IBOutlet NSView* theMapWindow; @property (assign) NSPoint drawPoint; @end -- @implementation mapWindow @synthesize theMapWindow, drawPoint; - (void)mouseDown:(NSEvent *)event { NSPoint point = event locationInWindow; NSLog(@"%@ %@ mouseDown location == %@", NSStringFromClass(self class), NSStringFromSelector(_cmd), NSStringFromPoint(point)); self setDrawPoint:point; self setNeedsDisplay:YES; //NSLog( @"mouseDown location: (%f,%f)", (float) point. X, (float) point.

Y); //self drawRect:point. X:point. Y; } - (void)drawRect:(NSRect)frame { NSLog(@"Drawing point at %@", NSStringFromPoint(drawPoint)); NSRect drawFrame = NSMakeRect(point.

X, point. Y, 128.0, 128.0); NSBezierPath setDefaultLineWidth:4; NSColor whiteColor set; NSBezierPath fillRect:drawFrame; NSColor grayColor set; NSBezierPath strokeRect:drawFrame; }.

Point. X and point. Y can't be called because they don't exist.

– evdude100 Jun 5 at 13:26 I did however to get something similar done, thanks! I used NSPoint origin= self drawPoint; – evdude100 Jun 5 at 13:53.

You doing it wrong. You shouldn't call drawRect yourself, it will be called for you. Replace the call of drawRect with setNeedsDisplayInRect and remove setNeedsDisplayInRect from the drawRect method.

Did so and had no effect. – evdude100 Jun 5 at 3:11 edited for better solution – Dani Jun 5 at 3:12 so in other words: - (void)setNeedsDisplayInRect:(int)pointx: (int)pointy{insert..}? – evdude100 Jun 5 at 3:14 instead of self drawRect:point.

X:point. Y; do theMapWindow setNeedsDisplayInRect:rect; and remove theMapWindow setNeedsDisplayInRect:rect;. You have to generate the rect for the whole window because you don't have it.

– Dani Jun 5 at 3:16 that isn't drawRect: it is drawRect:: – Grady Player Jun 5 at 7:14.

Your drawRect:: is custom method, and not the same as drawRect:, it will not be called when you have your view as the current context, try throwing a self lockFocus,self unlockFocus around your drawing code.

Thank you for letting me know, Instead I'm going to make it a built in method. – evdude100 Jun 5 at 13:48.

I cant really gove you an answer,but what I can give you is a way to a solution, that is you have to find the anglde that you relate to or peaks your interest. A good paper is one that people get drawn into because it reaches them ln some way.As for me WW11 to me, I think of the holocaust and the effect it had on the survivors, their families and those who stood by and did nothing until it was too late.

Related Questions