(Crud -- Forgot to change the title again. Sorry about that. -- GA)
IMHO, you are trying to do this the hard way. I did one similar to that, using views, many years ago using MacApp. (Presented it at MadaCon in Phoenix.) I wouldn't do it that way again. Just draw everything in one view. Define a draw-shape object with lists of inputs and outputs (could be objects). Define the connecting lines however you want, as line-objects. If you want connector objects, define them. You can easily establish a recursive algorithm that ensures directionality and makes sure you don't connect more than one output to any input. You an even do (as I did) cut and paste which preserves inter-object connections. If you are not familiar with drawing code, spend some time with the Sketch example. It has a lot of code you can pilfer. However, I would suggest putting the code into controllers, not in the view and document like Sketch does. > Hi Everyone > > I've recently tried implementing a tool that functioned similar to Quartz > Composer (the tool was for an entirely different purpose, and I did not know > about Quartz Composer at the time). Basically, the user is presented with a > canvas. On the canvas, the user can place squares that represent components, > and these components can be linked together by dragging a line from one to > another. While, I did get an implementation working, I felt it was quite a > bit of hackery, and I'm wondering if anybody else has any experience with > such a user interface? For me, the hard part was figuring out which view > hierarchy the connecting lines belonged to. For example my view hierarchy > was NSWindow --> Canvas --> Components. A connecting line from one > component to another didn't seem to fit as a subview of any one component, > because its bounds were not within that of any single component - they were > between components. My solution was to create a clear CALayer for each > line, and that layer was owned by the canvas, not any component. Whenever a > component was moved on the screen, the appropriate lines needed to be > updated as well. My solution seemed, to me, to have far to many layers and > weak references. > > There are many applications like this: OmniGraffle, Keynote (to some > extent), OpenOffice, Reason, etc. Is this type of interface so common that > there are known "tricks" to solving the problem easier (I'm thinking > something analogous to a design pattern). Thanks a lot. > > > > -- > Darren Minifie > Computer Science Masters Candidate > University of Victoria, BC. Canada > My Rants: www.noisyair.com > My Band: www.ohsnapmusic.com > _______________________________________________ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) 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: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com