ThinkGeo.com    |     Documentation    |     Premium Support

Double-clicking a polyline vertex deletes vertex

If you select a polyline and double-click its vertex, the vertex is removed from the polyline. That is very beneficial behavior. However, we are trapping the double-click on the map control to display a context menu. So if the end-user double-clicks a polyline line segment, our context menu displays; if the end-user double-clicks a polyline vertex, the vertex is removed and our context menu displays. This confuses the end-user. We would like to suppress the context menu if the double-click deletes the vertex. What's the best way for us to detect a vertex has been removed?



 


Gregory,
 
Thanks for your post.
 
First of all, I just want to verify with you and make sure we are in the same boat. About the way of delete vertex, do you follow the HowDoI sample TrackAndEditShapes? I think that’s the recommended and easiest way to remove a vertex from poly line.
 
Another question is that when you double click on the map not on any vertex, will the map zoom in or not? If not, how do you make it so?
 
Normally, the context menu is shown by right click automatic, how do you show it by double click? I guess that you must hookup the MapMouseDoubleClick event of ExtentOverlay, and at the implemented method, you show it.
 
If you do like that, I think you can add an “if-statement” to let context menu show by conditions. You can define a Boolean module variable like isVertexDeleted, the default value is false. You hookup the VertexRemoved event of EditionOverlay, at the implemented method you set isVertexDeleted to true.
 
So, when you double click on a vertex, VertexRemoved event will be rasied first, and then MapMouseDoubleClick rasied, if isVertexDeleted is true you set it to false and don’t show the context menu. otherwise, show context menu.
 
Thanks
 
James

James, your approach "almost" works - the only problem is the timing of events. Evidently the MapMouseDoubleClick event fires BEFORE the VertexRemoving/VertexRemoved events, according to my testing. Is there a way for the events to fire in the order you describe, or a different approach you can think of?

Gregory,


I still don't know whether we are in the same boat or not, because some user is very careless and hookup the wrong event.


I doubt your conclusion, i don't think MapMouseDoubleClick event fires before VertexRemove event. Can you give me a small sample to prove that?


I made a sample to you, and you can see if VertexRemove event fired, the MapMouseDoubleClick won't be fired, because if it fired it will make map zoom in. And you don't answer my question: "Another question is that when you double click on the map not on any vertex, will the map zoom in or not? If not, how do you make it so? "


I am sorry if my words are something you fell not good, but I just want to make the thing clear and that can solve your problem efficiently. So it's good for you.


Please let me know if you have more questions


James



1595-TestEventOrder.zip (10.8 KB)

Gregory, 
  
   Don’t take some of James’s comments too literally.  I think he uses some phrases that are a little “charged” and might convey the wrong meaning.  For example using “I doubt your conclusion” isnt really great to say.  I will talk with him about his phrase choice,  sorry for it.  I know James pretty well and haver worked right beside him for at least a year I know he doesn’t mean it exactly as it same out on the page. 
  
 David

James, I neglected to answer the part of your original question where you ask how we suppress the double-click event from zooming in the map.  
  
 I change the interactive overlay on the map so that I can support the pan/zoom-to modes. I believe there is a project or discussion post that shows you how to do this. 
  
 My code reads: 
   
 ModeInteractiveOverlay interactiveOverlay = new ModeInteractiveOverlay(); 
 interactiveOverlay.DoubleLeftClickMode = MapDoubleLeftClickMode.Disabled; 
 interactiveOverlay.DoubleRightClickMode = MapDoubleRighttClickMode.Disabled; 
 winformsMap1.InteractiveOverlays[winformsMap1.InteractiveOverlays.Count - 1] = interactiveOverlay; 
 
 
  
 This effectively suppresses the double-click event from zooming in the map. 
  
 I will try out your sample using this form of the interactive overlay to see if it behaves differently. 
  
 David, no worries! James, Yale and you have saved our hides more times than I can count, so basically you guys can do no wrong! 
  


Gregory, 
  
 I agree David’s words that my phrases are not good. I apologize for that. 
 Thank you for forgiving me, I will make my replies better. 
  
 At the first time, I fell there maybe something different from default about InteractiveOverlays, because the default would not has double-click problem, so I ask some questions because I think they’re very important and will be helpful to solve your problem. For example, the first question you didn’t answer, so I think you use the same way of TrackAndEditShapes sample, you use the default interactive system, but the thing is not like that. The second question you didn’t answer, so I think you didn’t suppress zoom in with double click, but after I test I can not recreate it if use default. The last question you still didn’t answer, so I still don’t know how you show the context menu by double click, if it’s the same as my guess, I think there is no problem. So I think you use another way to show context menu, please let me know. 
  
 And now I think the things are clear. You use none-default interactive overlay ModeInteractiveOverlay, is it download from code.thinkgeo.com/projects/list_files/trackzoomwithout 
 when you set mode as Pan, it will suppress zoom in with key, so if you double click it won’t zoom in no matter you click on a vertex or not.  
 But even though, I still can not recreate your problem, I think there still something missing. Do you modify the ModeInteractiveOverlay? 
  
 I think this issue is very simple, but you already cost two days, I try to help everyone as soon as possible, I think your problem should be solve more early if you supply more informations. 
  
 Best wishes at the end of this year! 
  
 James