Re: Non-rectangular image of NSView for dragging
Re: Non-rectangular image of NSView for dragging
- Subject: Re: Non-rectangular image of NSView for dragging
- From: Kyle Sluder <email@hidden>
- Date: Sun, 19 Jun 2011 10:06:02 -0700
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
_______________________________________________
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