You shouldn't use just flat out position/localposition. Instead use UIWidget.localCorners. This gives you the local corner positions. Take the mouse position, ScreenToWorldPoint it so it's in world space, then widgetTransform.InverseTransformPoint it into local space. You now have a local rectangle, and a local point. The rest is easy.