CF - 如何在弹出ContextMenu时获取鼠标位置?
我有一个无法解决的问题。
在我看来(显示地图)我创建了一个 contextMenu。 当调用上下文菜单时,我需要获取用户在地图上单击的位置。
这是我的问题:
在视图中,我已经有 onMouseDown 事件,它可以获取用户单击的坐标。
private void MapView_MouseDown(object sender, MouseEventArgs e)
{
this.lastMouseDownX = e.X;
this.lastMouseDownY = e.Y;
}
当调用 contextMenu 时,我需要相同的数据,但问题是 contextMenu 仅具有不保留我需要的数据的 EventArgs。此外...当用户按住鼠标一秒钟时,将调用 contextMenu,并且当调用它时,代码不会进入 onMouseDown 事件!它只是进入我的上下文菜单上的弹出事件......
我尝试将其放入我的弹出事件中,但坐标不正确。 Y 坐标与图表相差甚远。
private void servicesContextMenu_Popup(object sender, EventArgs e)
{
this.lastMouseDownX = Control.MousePosition.X;
this.lastMouseDownX = Control.MousePosition.Y;
}
帮助?
I have a problem i cannot solve.
In my view (that shows a map) i created a contextMenu.
When context menu is invoked i need to get the position where the user has clicked on the map.
Here is my problem:
In the view i already have onMouseDown event that gets me the coordinates where the user clicked.
private void MapView_MouseDown(object sender, MouseEventArgs e)
{
this.lastMouseDownX = e.X;
this.lastMouseDownY = e.Y;
}
When the contextMenu is invoked i need the same data, but the problem is that contextMenu only has EventArgs that dont keep the data i need. Furthermore ... contextMenu is invoked when user presses and holds mouse for a second and when its invoked the code does not enter onMouseDown event ! It just goes into popup event on my context menu....
I tried putting this in my popup event, but the coordinates are not ok. Y coordinate is way off the chart.
private void servicesContextMenu_Popup(object sender, EventArgs e)
{
this.lastMouseDownX = Control.MousePosition.X;
this.lastMouseDownX = Control.MousePosition.Y;
}
Help?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
使用它帮助我完成了事情。
http://www.mofeel.net/58-microsoft -public-dotnet-framework-compactframework/19285.aspx
Using this helped me get things done.
http://www.mofeel.net/58-microsoft-public-dotnet-framework-compactframework/19285.aspx