alfiare
Topic Author
Posts: 28
Joined: 30 Nov 2017, 23:47

How to Keep Context Menu from Opening If Mouse Moved

01 Oct 2025, 21:38

I have a situation where holding down the right mouse button and moving the mouse effectively is panning a map on the screen. I want to have a context menu appear on right click but only if the map wasn't moved. It appears that the default Noesis context menu is opened when the right mouse button is released, how do I keep the context menu from opening when the right mouse is released if the mouse position is different from where it was when it was pressed?
 
User avatar
sfernandez
Site Admin
Posts: 3363
Joined: 22 Dec 2011, 19:20

Re: How to Keep Context Menu from Opening If Mouse Moved

06 Oct 2025, 16:47

This is the standard behavior for context menus, they show when mouse up is released over an element with its ContextMenu property set, even if the mouse was moved in between.

What you can do is listening to PreviewMouseRightButtonDown, PreviewMouseMove and PreviewMouseRightButtonUp events to check if the mouse was moved and mark the Up event as handled in that case, so context menu is not raised in that situation.

Could you try something like this?

Who is online

Users browsing this forum: Semrush [Bot] and 5 guests