• 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: Non-rectangular image of NSView for dragging
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Non-rectangular image of NSView for dragging


  • Subject: Re: Non-rectangular image of NSView for dragging
  • From: Martin Hewitson <email@hidden>
  • Date: Sun, 19 Jun 2011 19:36:53 +0200

I got an off-list reply suggesting clipping the final image with a bezier path. So I used NSBezierPath's addClip with the same path used in drawRect: for clipping my final image. Works perfectly.

Thanks to all for the suggestions!

Martin

On 19, Jun, 2011, at 07:06 PM, Kyle Sluder wrote:

> On Sun, Jun 19, 2011 at 6:46 AM, Martin Hewitson
> <email@hidden> wrote:
>> I have a view which contains a set of subviews. This control is a little like a collection view. I have drag-n-drop implemented but I'm having some trouble getting a decent image for dragging. The problem is that the subviews are not rectangular but have rounded corners. So far I'm using NSBitmapImageRep's -initWithFocusedViewRect to grab a screen-shot of the correct part of the screen. Unfortunately I can only specify the portion of the screen to grab using an NSRect. This results in the background of the main view being included in the dragging image. This looks kind of ugly. What I'd really like is to do the same but specify a bezier path instead. I was wondering if there is a better way to generate a drag image which properly reflects what the subview actually draws.
>
> Create a bitmap context and call -drawRect: recursively on your view
> hierarchy, setting up the graphics state and CTM appropriately as you
> go.
>
> You may want to factor out your drawing code from -drawRect: so that
> you can call it separately. That would be handy if you need to draw
> subtle differences between the in-view representation and the drag
> image.
>
> --Kyle Sluder

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Martin Hewitson
Albert-Einstein-Institut
Max-Planck-Institut fuer
    Gravitationsphysik und Universitaet Hannover
Callinstr. 38, 30167 Hannover, Germany
Tel: +49-511-762-17121, Fax: +49-511-762-5861
E-Mail: email@hidden
WWW: http://www.aei.mpg.de/~hewitson
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~





_______________________________________________

Cocoa-dev mailing list (email@hidden)

Please 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: 
 >Non-rectangular image of NSView for dragging (From: Martin Hewitson <email@hidden>)
 >Re: Non-rectangular image of NSView for dragging (From: Kyle Sluder <email@hidden>)

  • Prev by Date: Re: Automatically mirroring folders
  • Next by Date: Re: audiounit instrument with cocoa view
  • Previous by thread: Re: Non-rectangular image of NSView for dragging
  • Next by thread: Re: Non-rectangular image of NSView for dragging
  • Index(es):
    • Date
    • Thread