Cursor position is in absolute coordinates but SCanvas slots expect a position in relative coordinates. This is further compounded by the fact that the entire UI has a scaling factor applied depending on your resolution, so you have not only a translation offset but also a scaling offset.
Converting between the two is most easily done through FGeometry, using AbsoluteToLocal / LocalToAbsolute. In order for AbsoluteToLocal to mean anything to the canvas, though, it has to be the canvas’s geometry. Here’s an excerpt of how I’m doing it in our inventory:
My custom inventory SCompoundWidget exposes a delegate for OnMouseMove and my presenter registers for that. The SCanvas used for the drag and drop position is a child of that inventory widget and has the exact same geometry (no scaling, no padding, aligns set to fill), so that AbsoluteToLocal can return the proper coordinates. Then UpdateItemDragPos simply gets the Canvas slot for the drag indicator and manually updates its offsets.
If you can’t have the canvas take up the exact same geometry as a parent widget, you could also subclass SCanvas to override OnMouseMove and handle your positioning logic there.
SWidget only provides function overrides for input events, not delegates, so I simply inspired myself from SBorder’s pointer event delegates. It has a both a OnMouseMove Slate event and a setter for it. Then, to register for that event, either use Slate syntax or a setter: