Re: Drag and drop like in Interface Builder
Re: Drag and drop like in Interface Builder
- Subject: Re: Drag and drop like in Interface Builder
- From: "I. Savant" <email@hidden>
- Date: Thu, 2 Aug 2007 20:20:24 -0400
I want to implement drag and drop between two windows in my
application. How would I go about doing something like the way
interface builder does the connections? I.e. when the user clicks
and drags a line is drawn from the source to the cursor. I assume
this would have something to do with NSBezierPath?
For the drawing part, google and read "Cocoa Drawing Guide" (your
assumption is correct - NSBezierPath is what you're after). To get it
to draw between windows, you essentially need a transparent window
with a custom view on which to draw.
The transparent window / custom view assembly serves as a target
for your drawing since you're drawing things that happen across
multiple windows.
You'd set the transparent window's level to be above both the
other windows involved in the drag (we'll call them the drag
windows). You'd then set its frame rect to be equal to the union rect
of both drag windows. This will position it exactly over both drag
windows.
You'd then draw your drag line on the transparent window's custom
view to connect the beginning and end points, converting the points
between the views' and screen's coordinate systems.
--
I.S.
_______________________________________________
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