• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Drawing in view on mouse click
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Drawing in view on mouse click


  • Subject: Drawing in view on mouse click
  • From: geek <email@hidden>
  • Date: Sun, 28 Jul 2002 16:09:43 -0400

Hello World.

Well, here's my question: I have an view which contain the board for a simple board game and I want to print an image into the view everytime a click is performed inside the view bounds. So far I have done this:

- (void)mouseDown:(NSEvent *)theEvent {
NSPoint loc = [self convertPoint:[theEvent locationInWindow]
fromView:[[self window] contentView]];

xCoord = loc.x
yCoord = loc.y;
[self setNeedsDisplay:YES];

}
- (float)getXPos {
return xCoord;
}
- (float)getYPos {
return yCoord;
}

-(void)drawRect:(NSRect)rect {
int i;
NSImage *pion = [[NSImage alloc]initByReferencingFile:@"xRed.png"];

[...] (code to display the board grid.

[pion compositeToPoint:NSMakePoint([self getXPos], [self getYPos]) operation:NSCompositeCopy];
[self setNeedsDisplay:YES];
}


People on IRC have pointed me to the compositeToPoint: thing and at this time, nothing is working. The image isn't displaying on clicks.

Any suggestion to ad to this code?
_______________________________________________
cocoa-dev mailing list | email@hidden
Help/Unsubscribe/Archives: http://www.lists.apple.com/mailman/listinfo/cocoa-dev
Do not post admin requests to the list. They will be ignored.

  • Prev by Date: Re: _assign__t18string_char_traits1ZcRcRCc link undefined sym?
  • Next by Date: Re: mutable deep copying?
  • Previous by thread: Re[THE FIX]: _assign__t18string_char_traits1ZcRcRCc link undefined sym?
  • Next by thread: Re: cocoa-dev digest, Vol 2 #1008 - 12 msgs
  • Index(es):
    • Date
    • Thread