• 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
Resizing NSView with handles
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Resizing NSView with handles


  • Subject: Resizing NSView with handles
  • From: Matt Mashyna <email@hidden>
  • Date: Tue, 10 Apr 2007 18:02:52 -0400

I have an NSView subclass that I want to be able to resize by clicking and dragging handles on the corners. Maybe I'm not going about it in the right way. I catch the click on the appropriate handle, change the frame of my view, call setNeedsDisplay and finally recalculate where the handles should be after dragging.

It works... if I drag slowly. If I move the mouse too fast I seem to loose my grip on the handle and it stops resizing.


- (void)mouseDragged:(NSEvent *)theEvent { NSPoint myOrigin = [self frame].origin; NSRect myOriginalRect = [self frame];

NSRect tempRect = [self frame]; // we'll drag if we're in the box frame
NSPoint tempPoint = [self convertPoint:[theEvent locationInWindow] fromView: nil]; // convert the click point to our coord system

...

if(NSPointInRect(tempPoint, URhandle)) // URhandle is an NSRect for the Upper Right corner
{
NSSize newsize = NSMakeSize(myOriginalRect.size.width + [theEvent deltaX],
myOriginalRect.size.height - [theEvent deltaY]);
[self setFrameSize: newsize]; // change the frame size
[[self superview] setNeedsDisplayInRect: myOriginalRect]; // tell it to update
[self setNeedsDisplay: YES]; // tell us to update
[self calculateHandlePositions]; // recalculate our handle locations
return;
}
}
_______________________________________________


Cocoa-dev mailing list (email@hidden)

Do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden


  • Follow-Ups:
    • Re: Resizing NSView with handles
      • From: "I. Savant" <email@hidden>
  • Prev by Date: Re: pointer address changes for no reason
  • Next by Date: Re: pointer address changes for no reason
  • Previous by thread: [JOB] Cocoa Developer, Madison WI
  • Next by thread: Re: Resizing NSView with handles
  • Index(es):
    • Date
    • Thread