I am attempting to implement a generic moving widget with a single content slot but have run into an issue getting the mouse position relative to the widget being moved.
Youtube video example of bug: - YouTube
It appears as though the result from Absolute to Local in MouseMove is acting erratically depending on the mouse position, which I guess is caused by a flaw in my logic. The offset is staying constant and the screen position is working correctly.
Am I setting the widget’s position incorrectly, or am I getting the relative position incorrectly?
Turns out this is not the best way to do moving widgets.
Instead use drag-drop. Implement OnMouseDown on the draggable widget (say a generic draggable border). Add a function call to “Detect Drag If Pressed” and return the result. Also override OnDragDetected, where you create a drag drop operation and add your draggable widget as the payload and default drag visual. Return this operation.
In another external widget, such as a “UI” widget that contains your draggable widgets, override OnDrop. Break open the operation in OnDrop and cast the operation’s payload to your draggable widget. Set the newly cast widget’s parent to self. Also you can set the position of the new widget to the mouse position, or whatever you want.
And there you have draggable widgets.