I’m fighting hard to implement some Drag&Drop. I noticed that reading the mouse position during a Drag (at least in OnDrop()) gives 0,0 or -1,-1 depending on what function you use.
I use these functions:
FIntPoint Common::GetMousePos()
{
if (!world) return FIntPoint(0, 0);
FIntPoint mc;
FViewport* v = CastChecked<ULocalPlayer>(world->GetFirstPlayerController()->Player)->ViewportClient->Viewport; //
v->GetMousePos(mc); // this gives -1,-1
return mc;
}
and:
FIntPoint Common::MouseToScreenPos()
{
if (!world) return FIntPoint(0, 0);
float mx, my;
mx=my= 0.0f;
APlayerController* pc = world->GetFirstPlayerController();
if (pc && pc->GetMousePosition(mx, my)) //GetMousePosition() returns false
{
float Scale = UWidgetLayoutLibrary::GetViewportScale(pc);
mx = mx / Scale;
my = my / Scale;
}
FIntPoint mc(mx, my);
return mc;
}
Is this a bug or design? Thanks so far.