Background_SingleClicked Question


#1

Hi,
I have a Background_SingleClicked sub that enables the user to copy nodes from the palette directly to the document without dragging and dropping. With just a single click on the background, the node appears on the background. This functionality works great until I load a graph from a file. When I do this, the Background_SingleClicked sub is not immediately called when I click on the background - it takes several tries to finally prompt the sub to take action. Do you have any idea why it doesn’t respond right away?? Am I not setting something correctly when I load the document??
Joy


#2

no idea, actually. Have you tried just replacing the view’s GoDocument programmatically (not involving save/load), to see if that had any bad effect?
Do you have any code operating on focus change events?


#3

I don’t have any on focus change events in my code and what exactly do you mean by “replacing the view’s GoDocument programmatically”? During the load process I am adding nodes and links to the interface document programmatically. But you are suggesting that I try something else in addition to this? or instead of this??
Joy


#4

I was just wondering if your re-creation of objects in a document wasn’t working right, so that some objects thought they covered areas where you thought there would be nothing (i.e. background).
You can programmatically replace a view’s document by setting the GoView.Document property.
If you define a GoView.ObjectSingleClicked event handler, does it get called instead of the BackgroundSingleClicked event handler?


#5

No the GoView.ObjectSingleClicked event handler does not get called instead of the BackgroundSingleClicked event handler. And I know how to set the view’s document property programmatically - I just didn’t understand how you were suggesting I use it to test what is taking place in my code. So would you mind explaining that point again to me please?
It’s almost like the view does not have the focus at first and that I need to click on it to set the focus. But when I load a file I do this:
If Not doc Is Nothing Then
Dim w As NetworkWindow = New NetworkWindow
w.View.Document = doc
w.WindowState = FormWindowState.Maximized
w.View.ZoomNormal()
w.View.Enabled = True
w.View.Focus()
w.MdiParent = mdiparent
w.Show()
w.Activate()
Return w
End If
So I don’t know what else I should do. I don’t encounter this problem when I create new documents, only when I load them.
Joy


#6

I was just wondering if the (improper) presence of any objects in the document might be causing the problem. So in your code, I would try:
w.View.Document = new GoDocument()
just to see if that has the same result as setting it to the “doc” document that you have loaded. The next step might be to use a document that you have “loaded”, but that you explicitly haven’t created any objects in.
If it is a focus problem, perhaps you should call GoView.Focus() after you call NetworkWindow.Activate().