ThinkGeo.com    |     Documentation    |     Premium Support

How to cancel currently drawing shape

Hi, I wanted to implement a cancel functionality to our application.

I tried subscribing to the Map Keydown event, however it never triggers when pressing a key.

Map.TrackOverlay.MapKeyDown += Map_KeyDown;
    
private async void Map_KeyDown(object sender, MapKeyDownInteractiveOverlayEventArgs e)
    {

        Map.TrackOverlay.TrackShapeLayer.InternalFeatures.Clear();
        try
        {
            await Map.RefreshAsync(Map.TrackOverlay);
        }
        catch { }

    }

I also tried subscribing to

Map.KeyDown += Map_KeyDown;
private async void Map_KeyDown(object sender, KeyEventArgs e)

however, that breakpoint is also never hit. I couldnt find anything in the HowDoI, so could you please assist me?

Map Implementation is

        </ContentControl>

Thanks

Can you try Map.ExtentOverlay.MapKeyDown for a quick?

Hi Ben, I just tried
Map.ExtentOverlay.MapKeyDown += OnKeyDown;
and it also does not fire an event.

Please first, make sure the map is focusable
mapView.Focusable = true;

then either focus it programmatically:
mapView.Focus();
or do
mapView.MapFocusMode = MapFocusMode.MouseEnterFocused; to make it automatically being focused.

In fact, we’ll make it Focusable by default in the future versions.

Oh, yeah, that worked, thanks! Is there a performance benefit of keeping it not focusable? Wondering if it is worth it only enabling that during draw operations

No, there’s no meaningful performance benefit. You can keep it true.

1 Like