From 7baf07f29bdccd83b9fa62242de13938738d9423 Mon Sep 17 00:00:00 2001 From: Steve Streeting Date: Mon, 26 Oct 2020 17:40:02 +0000 Subject: [PATCH 1/2] Support setting up Options widget content in design view --- Source/StevesUEHelpers/Private/StevesUI/OptionWidgetBase.cpp | 3 ++- Source/StevesUEHelpers/Public/StevesUI/OptionWidgetBase.h | 2 ++ 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/Source/StevesUEHelpers/Private/StevesUI/OptionWidgetBase.cpp b/Source/StevesUEHelpers/Private/StevesUI/OptionWidgetBase.cpp index af5152e..7352430 100644 --- a/Source/StevesUEHelpers/Private/StevesUI/OptionWidgetBase.cpp +++ b/Source/StevesUEHelpers/Private/StevesUI/OptionWidgetBase.cpp @@ -16,7 +16,6 @@ void UOptionWidgetBase::NativeConstruct() { GS->OnInputModeChanged.AddDynamic(this, &UOptionWidgetBase::InputModeChanged); UpdateFromInputMode(GS->GetLastInputModeUsed()); - ClearOptions(); } else UE_LOG(LogStevesUI, Error, TEXT("StevesGameSubsystem is missing!")); @@ -44,6 +43,8 @@ void UOptionWidgetBase::NativeConstruct() UE_LOG(LogStevesUI, Error, TEXT("%s should have a GamepadDownImage instance."), *this->GetClass()->GetName()); + // To support option set up in designer + SetSelectedIndex(SelectedIndex); } diff --git a/Source/StevesUEHelpers/Public/StevesUI/OptionWidgetBase.h b/Source/StevesUEHelpers/Public/StevesUI/OptionWidgetBase.h index 0794e1d..2fd51f9 100644 --- a/Source/StevesUEHelpers/Public/StevesUI/OptionWidgetBase.h +++ b/Source/StevesUEHelpers/Public/StevesUI/OptionWidgetBase.h @@ -118,7 +118,9 @@ public: protected: + UPROPERTY(EditAnywhere, BlueprintReadOnly, Category=Content) TArray Options; + UPROPERTY(EditAnywhere, BlueprintReadOnly, Category=Content) int SelectedIndex; virtual void SyncButtonProperties(UButton* Button) const; From c0650d2c09772d9a8779d9fb23d2baee090a0dd0 Mon Sep 17 00:00:00 2001 From: Steve Streeting Date: Mon, 26 Oct 2020 17:40:32 +0000 Subject: [PATCH 2/2] Seems we need to SynchronizeProperties more often to make sure slate widgets get style --- .../Private/StevesUI/OptionWidgetBase.cpp | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/Source/StevesUEHelpers/Private/StevesUI/OptionWidgetBase.cpp b/Source/StevesUEHelpers/Private/StevesUI/OptionWidgetBase.cpp index 7352430..c5255ff 100644 --- a/Source/StevesUEHelpers/Private/StevesUI/OptionWidgetBase.cpp +++ b/Source/StevesUEHelpers/Private/StevesUI/OptionWidgetBase.cpp @@ -42,7 +42,9 @@ void UOptionWidgetBase::NativeConstruct() if (!GamepadDownImage) UE_LOG(LogStevesUI, Error, TEXT("%s should have a GamepadDownImage instance."), *this->GetClass()->GetName()); - + + SynchronizeProperties(); + // To support option set up in designer SetSelectedIndex(SelectedIndex); } @@ -167,6 +169,9 @@ void UOptionWidgetBase::SetMouseMode() } MouseVersion->SetVisibility(ESlateVisibility::Visible); + + SynchronizeProperties(); + if (bHadFocus) SetFocusProperly(); @@ -182,6 +187,9 @@ void UOptionWidgetBase::SetButtonMode() MouseVersion->SetVisibility(ESlateVisibility::Hidden); GamepadVersion->SetVisibility(ESlateVisibility::Visible); + + SynchronizeProperties(); + if (bHadFocus) SetFocusProperly();