Re: What am I doing wrong in my drag loop? [solved]
Re: What am I doing wrong in my drag loop? [solved]
- Subject: Re: What am I doing wrong in my drag loop? [solved]
- From: "John C. Randolph" <email@hidden>
- Date: Wed, 20 Jul 2005 12:07:59 -0700
Dave,
You've made this a lot more complicated than necessary. Here's a
view that does what you want:
#import "MyView.h"
@implementation MyView
- (id)initWithFrame:(NSRect)frameRect
{
if ((self = [super initWithFrame:frameRect]) != nil) {
// Add initialization code here
}
return self;
}
- (void)drawRect:(NSRect)rect
{
[[NSColor redColor] set];
NSRectFill(rect);
}
- (void) mouseDragged:(NSEvent *) theEvent
{
NSPoint where = [self frame].origin;
id superview = [self superview];
[superview setNeedsDisplayInRect:[self frame]];
[self setFrameOrigin:NSMakePoint(where.x + [theEvent deltaX],
where.y - [theEvent deltaY])];
[superview setNeedsDisplayInRect:[self frame]];
}
@end
-jcr
John C. Randolph <email@hidden> (408) 914-0013
Roaming Cocoa Engineer,
Available for your projects at great Expense and Inconvenience.
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Cocoa-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden