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

Re: Resizing NSView with handles


  • Subject: Re: Resizing NSView with handles
  • From: "I. Savant" <email@hidden>
  • Date: Wed, 11 Apr 2007 12:48:50 -0400

On 4/10/07, Matt Mashyna <email@hidden> wrote:
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.


...

                NSSize  newsize = NSMakeSize(myOriginalRect.size.width + [theEvent
deltaX],
                        myOriginalRect.size.height - [theEvent deltaY]);
                [self setFrameSize: newsize];                                                                   // change the frame size

How about, instead of using the event delta, you determine the actual current location and figure out the size with that information? All you care about is where the pointer is right now, not how far it moved during the event. Depending on which handle is being dragged, you adjust the geometry of your view to make sure that handle now matches the x, y, or both of the new mouse pointer position (considering constraints like min/max size, etc.).

--
I.S.
_______________________________________________

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


References: 
 >Resizing NSView with handles (From: Matt Mashyna <email@hidden>)

  • Prev by Date: Re: Multi windows in Document-based app, but 1 Nib
  • Next by Date: Re: WM_KEYDOWN
  • Previous by thread: Resizing NSView with handles
  • Next by thread: CoreData Updating Max pk error?
  • Index(es):
    • Date
    • Thread