SubSubGraph and OnSelectionDropReject

Hello,

I have the situation where I have a SubGraph S1, that contains a SubSubGraph S2. I try to drag&drop a node to S2. I have overloaded OnSelectionDropReject for my subgraphs.

First, S2.OnSelectionDropReject is called, returning false, since the node can be dropped into S2. But then S1.OnSelectionDropReject is called too. This call returns true, since the node cannot be dropped into S1 (there is a name conflict). Therefore, the whole result is that the node cannot be dropped into S2.

Is there any way to change this hierarchical behaviour, since in my application, deciding wether a node can be dropped within a subgraph only depends on the subgraph itself, not on the subgraph(s) in which the subgraph is placed.

Regards,

Here’s one way of doing it – by making the parent subgraph’s OnSelectionDropReject smarter, recognizing when the mouse is in the parent subgraph but not in the child subgraph.
This code assumes you are dragging around a GoIconicNode, and is testing for that. It also assumes the subgraphs have PickableBackground set to true, which simplifies recognizing which subgraph the mouse seems to be “in”.
[Serializable]
public class TestSubGraph3 : GoSubGraph {
public TestSubGraph3() {
this.Text = “Channel 1”;
this.LabelSpot = GoObject.TopLeft;
this.CollapsedLabelSpot = GoObject.TopLeft;
this.PickableBackground = true;
this.BorderPen = Pens.Black;
this.BackgroundColor = Color.Red;
this.Opacity = 100;
this.TopLeftMargin = new SizeF(15, 10);
this.BottomRightMargin = new SizeF(15, 10);
TestSubGraph4 sg1 = new TestSubGraph4();
sg1.Text = “Ex”;
sg1.Position = new PointF(50, 50);
Add(sg1);
TestSubGraph4 sg2 = new TestSubGraph4();
sg2.Text = “Em”;
sg2.Position = new PointF(100, 50);
Add(sg2);
}
public override bool OnSelectionDropReject(GoView view) {
return Pick(view.LastInput.DocPoint, true) == this;
}
}
[Serializable]
public class TestSubGraph4 : GoSubGraph {
public TestSubGraph4() {
this.LabelSpot = GoObject.TopLeft;
this.PickableBackground = true;
this.BorderPen = Pens.Black;
this.BackgroundColor = Color.Yellow;
this.Opacity = 100;
this.Corner = new SizeF(10, 10);
this.TopLeftMargin = new SizeF(5, 10);
this.BottomRightMargin = new SizeF(5, 10);
GoIconicNode n = new GoIconicNode();
n.Initialize(null, “star.gif”, null);
Add(n);
}
public override bool OnSelectionDropReject(GoView view) {
foreach (GoObject obj in view.Selection) {
if (!(obj is GoIconicNode)) return true;
}
return false;
}
public override bool OnSelectionDropped(GoView view) {
AddCollection(view.Selection, true);
return true;
}
}

Thank you once more for you advise, it should do the trick !