• 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
Re: What am I doing wrong in my drag loop? [solved]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

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


References: 
 >What am I doing wrong in my drag loop? Dragging jumps all over the place. (From: Dave Camp <email@hidden>)
 >Re: What am I doing wrong in my drag loop? [solved] (From: Dave Camp <email@hidden>)

  • Prev by Date: NSPopupButton contentObjects binding
  • Next by Date: Re: /.journal_info_block
  • Previous by thread: Re: What am I doing wrong in my drag loop? [solved]
  • Next by thread: Core Data Implementation question
  • Index(es):
    • Date
    • Thread