OnObjectGotSelection


#1

I have found that if I press the Ctrl key and then click on a node or a link, that the OnObjectGotSelection sub is not called. Why is this?
Also, when I select multiple objects with the rubberband tool, in the OnObjectGotSelection sub, the view.Selection.Count is always one, even if I have selected more than one object. Do you know why this is the case? It has me completely stumped!
Thanks!!
Joy


#2

Perhaps I’m doing the wrong thing, but I just tried adding the following override to a node class, and everything worked the way I expected:
public override void OnGotSelection(GoSelection sel) {
base.OnGotSelection(sel);
MessageBox.Show(sel.Count.ToString());
}


#3

Well here is the code I am using in VB.NET which I copied from the ProtoApp sample application:
Protected Overrides Sub OnObjectGotSelection(ByVal evt As GoSelectionEventArgs)
MyBase.OnObjectGotSelection(evt)
If Not myPrimarySelection Is Me.Selection.Primary Then
myPrimarySelection = Me.Selection.Primary
MainForm.App.EnableToolBarEditButtons(Me)
End If
End Sub
And then during run-time in the command line I ask
?Me.Selection.Count
and it always returns a value of 1 regardless of the number of objects selected. Maybe I just don’t understand exactly what this sub is supposed to do, but I assumed from the description that it would be called regardless of how an object is selected (including the Ctrl click method) and that the view it captures would contain all the selected objects. I just tried it in the ProtoApp sample application and it does the same thing so maybe you could take a look at it there to better understand what I am experiencing.
Thanks!
Joy


#4

I just added the following line:
MessageBox.Show(Me.Selection.Count.ToString())
after the MyBase.OnObjectGotSelection(evt) statement, and it worked fine.
Are you setting a break point or putting in some tracing statements at the beginning or the very end of the method override?


#5

Ok, I think I understand it now, I put the break point at this line:
MainForm.App.EnableToolBarEditButtons(Me)
which was only being called for Me.Selection.Primary. So the Me.Selection.Count at that point was always 1. Thanks for the help!! I understand how it works now!
Joy