Is there a way to override the CanExecute on the SketchEditor's AddCommand?

554
2
04-14-2021 03:48 PM
ChristopherPalmer99
New Contributor II

This may be a strange use case, but our Xamarin ArcGIS Runtime mobile application needs to implement the following behavior:

When sketching a polyline or polygon, we want the user to pan the map and use a crosshair and a button to add vertices to the end of the sketch. However, we want the user to be able to use their finger to select and move vertices and to click midpoints to insert vertices (this isn't as important as the click to select and move, however - I'm not sure if that is covered by the AddCommand).

So basically, what we need is a way for CanExecute on the AddCommand to return false when we want it to, but for the other ICommands, they should behave as normal. Ideally, we'll have a switch in the UI to turn this "Touch to add vertex" on and off. Something like: CanExecute && TouchToAddVertex.

However, since the SketchEditor is sealed and the AddCommand is read only, I don't know if there is a way to do this, or if I'm missing anything.

We can make the SketchEditor visible, but not enabled, but that turns off the ability to select and move vertices. We want all the functions except add a vertex to the end on the touch gesture.

0 Kudos
2 Replies
JenniferNery
Esri Regular Contributor

Thanks for your feedback. You are right that there's no way of updating or providing your own predicate for AddCommand to have it respond only to touch event.

 

How are you passing the CommandParameter for AddCommand? This is only enabled with MapPoint. If you don't want AddCommand to execute and add vertex to your polyline/polygon, could you may be provide MapPoint  vertex only when a touch gesture is detected? Alternatively, you can call InsertVertexAfterSelectedVertex method with a more restrictive check.

Or you may pause SketchEditor from responding to interaction using its IsEnabled property. If only vertex-editing need to be suspended you can set SketchEditConfiguration.VertexEditMode to SelectionOnly.

ChristopherPalmer99
New Contributor II

I am using the command parameter to AddCommand to pass a MapPoint when I want to add a vertex at our crosshair. But I guess there's no way of doing what I'm after (preventing the addition of vertices by touch) without also suppressing the other vertex editing functionality. Oh, well.

I will experiment with the SelectionOnly mode and see if we can add our own tools for doing the moves.

0 Kudos