Hello,
I am developing an ArcGIS Pro SDK MapTool in C#.
I want to change the mouse cursor depending on whether the current mouse position is on a selected polygon feature or not.
For example:
- show `Hand` when the mouse is on the selected feature
- show `Cross` otherwise
At first, I implemented the check inside `OnToolMouseMove` using `QueuedTask.Run`, something like:
protected override void OnToolMouseMove(MapViewMouseEventArgs args)
{
_ = QueuedTask.Run(() =>
{
var mapPoint = MapView.Active.ClientToMap(args.ClientPoint);
bool isHit = GeometryEngine.Instance.Intersects(_selectedGeometry, mapPoint);
Cursor = isHit ? Cursors.Hand : Cursors.Cross;
});
base.OnToolMouseMove(args);
}However, this caused noticeable lag.
It looks like `QueuedTask` calls keep getting queued during mouse movement, and cursor updates become delayed.
I improved the behavior by preventing multiple simultaneous cursor checks and only processing the latest mouse position, but I still have these questions:
- Is there any official or recommended best practice for changing the cursor dynamically in a `MapTool` based on mouse position?
- Is there any way to avoid `ClientToMap` on every mouse move while still keeping correct hit-testing?
- Is the default `MapTool` cursor documented anywhere?I am currently using `Cursors.Cross` as the non-hit cursor, but I am not sure whether that matches ArcGIS Pro’s default tool cursor.
- More generally, what is the recommended pattern for high-frequency mouse-move processing in a `MapTool` when MCT access is required?
For context, the selected geometry may sometimes include multiple polygons, and possibly polygons with holes, so replacing the hit-test with a very rough custom approximation is not always ideal.
If anyone has sample code, recommendations, or experience with this kind of cursor handling, I would appreciate it.
Thank you.