Map.MouseLeftButtonDown not fired with EditGeometry

488
7
05-27-2014 06:21 AM
JorisBeckers
New Contributor
Hi,

I'm using the EditGeomtry class for moving polygons in a graphic layer, and I need to know when I'm dragging the graphic.
First I click the polygon, this starts the editing session. Then I can drag it around.

With the first click, both Map.MouseLeftButtonDown and Map.MouseLeftButtonUp are fired.
When I then hold my left button to drag the graphic, the Map.MouseLeftButtondDown is not fired. When I release, Map.MouseLeftButtonUp does get fired.

The problem is that I want the ButtonDown event to know that I started dragging the graphic.
Or is there another property to indicate this?

Map.MouseLeftButtonDown += (sender, e) =>
                {
                            editor.StartEdit(graphic);
                            editing = true;        
                };

void editor_GeometryEdit(object sender, EditGeometry.GeometryEditEventArgs e)
        {

            if (e.Action.ToString() == "EditCanceled")
            {
                editing = false;
            }


            else if (e.Action.ToString() != "EditStarted")
            {
                editor.StopEdit();
                editing = false;
            }
        }


Thanks
0 Kudos
7 Replies
AsserSwelam1
Occasional Contributor
Hi,

You can use MouseLEftButtonDown to detect that the dragging started, and set you flag to true.
Use MouseMove event to detect that you are dragging and moving the graphic, and check your flag if true do what you want to do while dragging.
And MouseLeftButton up to detect the end of dragging and the release of the graphic, and set your flag to false.

-Asser
0 Kudos
JorisBeckers
New Contributor
Thanks for the reply!

The problem is that, from the moment the editor.StartEdit is called, I don't receive any MouseLEftButtonDown events anymore. When the dragging is finished, I get the GeometryMoved action, I stop the editing, and then I get the 'MouseLeftButtonUp'.

Any thoughts on how to get something similar to the MouseLeftButtonDown event when the editor is already started?

Thanks,
Joris
0 Kudos
AsserSwelam1
Occasional Contributor
Did you try using GraphicLayer MouseLeftButtonDown event instead of the map?

-Asser
0 Kudos
JorisBeckers
New Contributor
I did. With the same result...
But how does the EditGeometry tracks the dragging then?
Or is there maybe a way to drag a polygon with the first click?
Now I have to make the polygon editable by clicking on it, and then I have to click again to drag it.

Thanks,
Joris
0 Kudos
JorisBeckers
New Contributor
Hi,

I created a sample project of it with Silverlight 5 and the 3.1 API. You can dowload it here

To reproduce my problem:

1) Click on a ship. In the output window of VS, you see the Featurelayer.Buttondown, the Map.Buttondown, the Map.MouseButtonUp and the EditGeometry.Action.EditStarted are fired.
The object is now focused and read to be dragged.

2) If you click again, you ONLY get LeftButtonUp event and EditCanceled action. So NO buttondown.

3) Click again on a ship to start editing, this gives the same as 1.

4) Click outside the focused object, you get the Map.ButtonDown and Map.ButtonUp

5) Hold your mouse left button down within the focused object. You see that there is NO Map.LeftButtonDown fired, nor a FeatureLayer.ButtonDown.

6) Drag the object and release: You get the MousLeftButtonUp and the GeometryMoved action.

What I thus need I in step 5, a certain LeftButtonDown event.
One of my thoughts was that from the moment you start editing, the object is transferred to a new object. And maybe I need NewObject.MouseLeftButton down. But I�??ve no idea on how to find that object.

Do you maybe have an idea or trick to solve this?
Thanks!
0 Kudos
AsserSwelam1
Occasional Contributor
Hi thanks for providing a sample code.

I understand your problem, would you please tell me what exactly do you need to do by tracking the moving graphic?

What you will do or show when you know that the user is actually moving the editing graphic?

Thanks,
Asser
0 Kudos
JorisBeckers
New Contributor
Hi,

I actually need two related things:
1) I have another points layer and I need to find the closest point at every moment in time
2) I want to draw a line between the ship and that point. This line thus has to move together with the ship while dragging it.

I can do all this by grabbing the geometry in the MouseMove event. But I only want this geometry while dragging, and therefore i need to know when the dragging started.

Thanks,
Joris
0 Kudos