I want to show context menu based on user selection. For this, I have over-ridden the - OnMouseUp - method. However, when I call
my last input is gone/removed from the selection.
I have two questions in this regard -
1. Why does this happen?
2. How can I stop it from happening?
Set GoView.ContextClickSingleSelection to false.
This doesn’t seem to work.
public partial class Form1 : Form
public GoDocument diagram;
public GoView view;
public GoGeneralNode node1, node2;
private void AddGoObjects()
this.view = new GoView();
this.diagram = view.Document;
this.view.Dock = DockStyle.Fill;
this.view.ContextClickSingleSelection = true;
this.node1 = new GoGeneralNode();
this.node1.Size = new SizeF(30, 30);
this.node1.Resizable = false;
this.node1.Position = new PointF(50, 50);
this.node2 = new GoGeneralNode();
this.node2.Size = new SizeF(30, 30);
this.node2.Resizable = false;
this.node2.Position = new PointF(100, 100);
protected override void OnMouseUp(MouseEventArgs e)
What I want to do is, select multiple objects (by pressing ctrl) and then display the context menu based on the selection.
Since I want to show my context menu, I will have to put the logic inside OnMouseUp. But when I do that, the last object gets de-selected.
Am I missing something? How can I make it work the way I want?
Oops. Sorry about the previous post. If I set ContextClickSingleSelection to false, it does seem to work in the above example.
But it doesn’t seem to work in my app… :(
No, for context menus you should either override GoObject.OnContextClick or define a GoView.ObjectContextClicked and/or BackgroundContextClicked event handler.
In 2.5 you’ll be able to override GoObject.GetContextMenu.
Thanks walter, for the suggestion. At the moment, we are using ToolStripMenuItem provided by the .Net framework. Since substantial code has already been written for the various context menu’s we need, I am afraid we will not change to GoView.ObjectContextClicked at this point. However, I have showed your response to my manager and he says we can work on the change later.
Also, to the original problem I had, setting GoView.ContextClickSingleSelection to false works like a charm!