Hi,
So I’m trying to write simple slate code to check if the mouse is currently under any widget spawned or just under the viewport.
This is my code for the bool
TSharedPtr ViewPort = FSlateApplication::Get().GetGameViewport();
FWidgetPath WidgetUnderMouse = FSlateApplication::Get().LocateWindowUnderMouse(FSlateApplication::Get().GetCursorPos() , FSlateApplication::Get().GetInteractiveTopLevelWindows(), true);
bool bMouseUnderVieport = WidgetUnderMouse.IsValid() && WidgetUnderMouse.GetLastWidget() == ViewPort.ToSharedRef();
if (bMouseUnderVieport)
{
GEngine->AddOnScreenDebugMessage(0, 4.f, FColor::Red, FString::Printf(TEXT("Under Viewport")));
}
I’m getting this compilation error:
D:\Program Files\Epic Games\UE_5.0\Engine\Source\Runtime\Core\Public\Templates\SharedPointer.h(1697): error C2446: '==': no conversion from 'ObjectType *' to 'ObjectType *'
with
[
ObjectType=SViewport
]
and
[
ObjectType=SWidget
]
Not sure why this is not working since SViewport should inherit from SWidget and I did see some other post that suggest to use the same technique.
What am I doing wrong?
Here is a link to that post