ContextMenu + MouseMove issue

  • Thread starter Thread starter lukasz
  • Start date Start date
L

lukasz

I call contextMenu.Show() in OnMouseDown handler the menu shows and then I
press mouse button in other area to hide the menu (without selecting an
option). Then I receive first OnMouseUp event, next OnMouseMove, which is
very unwanted behavior in my case -- I would prefer to first know that the
cursor has moved (and it has moved), only then the fact that a mouse button
was pressed. Is there a solution for this? Note: I have not added the
ContextMenu to a container or whatever.
 
What excatly are you trying to do?...Maybe there is a better way to tackle
the task.
 
I have a control that allows drawing and modifying shapes. I provide context
menu to access common tasks for a chosen shape. So I override OnMouseMove
for dragging shapes and OnMouseDown, OnMouseUp to set dragging flag if LMB
was pressed, or show the context menu if RMB was pressed. If the menu is
cancelled by a mouse click, the app gets nuts and moves shapes because:

1. it detects RMB down on the shape, so it selects current shape and popups
the menu for the shape
2. it detects LMB down in an away location -- since there was no mouse move
in the meantime, it assumes it is valid situation to enable moving the shape
3. now come the previous mouse move events (that should have occurred
between steps 1 & 2), and the shape is being moved (moving is in OnMouseMove
to allow interactive moving)
4. finally mouse up is fired (in the same position as mouse down since it
was merely a click) and the moving operation is finalized.

I either want step 3. to come after step 1., or an idea how to get around
this issue.
 
Back
Top