Set focus correctly on Custom Button
This commit is contained in:
parent
8fba6df0db
commit
1fea57b459
BIN
Content/Widgets/BP_CustomButton.uasset
(Stored with Git LFS)
BIN
Content/Widgets/BP_CustomButton.uasset
(Stored with Git LFS)
Binary file not shown.
BIN
Content/Widgets/MainMenu/BP_StarterButtonWIdget.uasset
(Stored with Git LFS)
BIN
Content/Widgets/MainMenu/BP_StarterButtonWIdget.uasset
(Stored with Git LFS)
Binary file not shown.
@ -19,6 +19,8 @@ void UCustomButton::NativeConstruct()
|
||||
ButtonBody->OnHovered.AddUniqueDynamic(this, &UCustomButton::OnButtonHovered);
|
||||
ButtonBody->OnUnhovered.AddUniqueDynamic(this, &UCustomButton::OnButtonUnhovered);
|
||||
|
||||
SetDesiredFocusWidget(ButtonBody);
|
||||
|
||||
SynchronizeProperties();
|
||||
}
|
||||
|
||||
@ -39,7 +41,6 @@ void UCustomButton::SynchronizeProperties()
|
||||
void UCustomButton::NativeOnAddedToFocusPath(const FFocusEvent& InFocusEvent)
|
||||
{
|
||||
Super::NativeOnAddedToFocusPath(InFocusEvent);
|
||||
|
||||
OnFocused.Broadcast(InFocusEvent);
|
||||
OnButtonHovered();
|
||||
}
|
||||
|
@ -6,6 +6,7 @@
|
||||
#include "CustomButton.h"
|
||||
#include "StarterWeaponButtonDataObject.h"
|
||||
#include "StarterWeaponButtonWidget.h"
|
||||
#include "Components/Button.h"
|
||||
#include "Components/ScrollBox.h"
|
||||
#include "Kismet/GameplayStatics.h"
|
||||
|
||||
@ -29,8 +30,14 @@ void USelectWeaponWidget::NativeConstruct()
|
||||
Temp->SetData(Weapon, this);
|
||||
Widget->SetData(Temp);
|
||||
StarterWeaponsScrollBox->AddChild(Widget);
|
||||
Buttons.Push(Widget);
|
||||
}
|
||||
}
|
||||
|
||||
if (Buttons.Num() > 0)
|
||||
{
|
||||
Buttons[0]->SetKeyboardFocus();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -45,4 +45,6 @@ protected:
|
||||
private:
|
||||
UFUNCTION()
|
||||
void BackButtonClicked();
|
||||
|
||||
TArray<TObjectPtr<UStarterWeaponButtonWidget>> Buttons;
|
||||
};
|
||||
|
Loading…
x
Reference in New Issue
Block a user