views:

18

answers:

0

Hello! I want to create a functionality in a program to link two views (inside another view) using links like when CTRL+Dragging in Interface Builder.

In the implementation I have currently, there are 2 (or more) subclassed NSControllers (called Nodes) and inside those nodes there are 1 (or more) subclassed NSControllers (called Outlets).

So, the view hierarchy would be like so:

+ View (Workflow)
++ Node
+++ Outlet
++ Node
+++ Outlet
++ Node
+++ Outlet
+++ Outlet
++ Node
+++ Outlet

and so on...

What I want to do is to link those outlets together using something like "Drag and Drop", so that, when linking, there should display a link from the source to the destination. This link should disappear after the linking is done and the "valid" destination should highlight once we hover the mouse on top of it.

I've tried tampering with "mouseDragged:" selector, "mouseEntered:" selector (yes, i created a Tracking Rect), but i seem to be missing something, or maybe i'm looking at the other way. I've managed to draw a line from the origin Outlet to anywhere inside the workflow view, but i can't drop it inside the destination, since the "mouseEntered:" event is only fired when i release the mouse (thus, i don't know where i released the link nor i can highlight my destination control).

Any help in pointing me to the right direction is much appreciated!