Hello, I am currently working on an inventory system where pressing I opens the inventory.
My player controller looks something like this
void ATestHUD::OpenInventory()
{
if (Viewport && bIsInventoryOpen == false)
{
SAssignNew(MainInventoryUI, SInventoryWidget)
.InvStorage(StoragePtr);
Viewport->AddViewportWidgetContent(
SNew(SWeakWidget).PossiblyNullContent(MainInventoryUI.ToSharedRef())
);
SAssignNew(CursorItemUI, SCursorItemWidget)
.InvStorage((StoragePtr));
Viewport->AddViewportWidgetContent(
SNew(SWeakWidget).PossiblyNullContent(CursorItemUI.ToSharedRef())
);
CursorItemUI.Get()->SetVisibility(EVisibility::HitTestInvisible);
bIsInventoryOpen = true;
}
}
void ATestHUD::CloseInventory()
{
if (bIsInventoryOpen == true)
{
Viewport->RemoveAllViewportWidgets();
bIsInventoryOpen = false;
}
}
It works fine but at the start my mouse doesn’t focus to the slate view port. I have to click once to get it focused.
A lot of things have changed in 4.6 and old things in the answerhub don’t seem to work.
How do I focus to my slate and change the focus work? Something like SetUserFocus but I am not sure how to call it.
FSlateApplication::Get().SetUserFocus(1, MainInventoryUI);
This is such a simple thing basically each and every menu, inventory system uses it but why isn’t it documented at all?