CF - How to get the position of the mouse when the ContextMenu appears?
I have a problem that I cannot solve.
In my view (which shows the map), I created a contextMenu. When the context menu is called, I need to get the position at which the user clicked on the map.
Here's my problem:
In the view, I already have an onMouseDown event that gets me the coordinates of where the user clicked.
private void MapView_MouseDown(object sender, MouseEventArgs e)
{
this.lastMouseDownX = e.X;
this.lastMouseDownY = e.Y;
}
When calling the contextMenu, I need the same data, but the problem is that the contextMenu only has an EventArg which doesn't contain the data I need. Also ... the contextMenu is called when the user presses and holds the mouse for a second, and when the code is called, the onMouseDown event is not raised! It just goes to the popup event in my context menu ....
I tried to put this in my popup event but the coordinates are not ok. The y-coordinate is off-plot.
private void servicesContextMenu_Popup(object sender, EventArgs e)
{
this.lastMouseDownX = Control.MousePosition.X;
this.lastMouseDownX = Control.MousePosition.Y;
}
reference
a source to share
Using this helped me succeed.
http://www.mofeel.net/58-microsoft-public-dotnet-framework-compactframework/19285.aspx
a source to share