AnsweredAssumed Answered

Looking for effective way to detect mouse over graphics

Question asked by HuyHo on Oct 16, 2015
Latest reply on Jun 19, 2017 by mangoyoga

In our application, we would like to change the mouse cursor whenever the user hover the mouse over a graphic.  We've came up with a way to do it using the GraphicsLayer.HitTestAsync() method whenever the mouse move.  But I am not sure if this is the best way to do it because as I move my mouse over the map, my CPU spikes to 10-15%.  I think this is too costly in terms of performance for such a simple feature.

 

    private async void MapView_MouseMove(object sender, MouseEventArgs e)
    {
        Graphic graphic = await HitTestAsync(_mapView, e.GetPosition(_mapView));
        UpdateHoveringGraphic(graphic);
    }

 

The UpdateHoveringGraphic() function will then determine if the graphic has changed to generate a MouseEnter and MouseLeave event.

 

We have several GraphicsLayer, so this adds up.  Does anyone have any suggestions to accomplish this feature in a less resource intensive way?

 

Thanks.

Outcomes