diff --git a/Source/StevesUEHelpers/Private/StevesUI/FocusableButton.cpp b/Source/StevesUEHelpers/Private/StevesUI/FocusableButton.cpp index 7af4838..f7d77b5 100644 --- a/Source/StevesUEHelpers/Private/StevesUI/FocusableButton.cpp +++ b/Source/StevesUEHelpers/Private/StevesUI/FocusableButton.cpp @@ -31,11 +31,16 @@ TSharedRef UFocusableButton::RebuildWidget() Cast(GetContentSlot())->BuildSlot(MyButton.ToSharedRef()); } + RefreshFocussedStyle(); + + return MyButton.ToSharedRef(); +} + +void UFocusableButton::RefreshFocussedStyle_Implementation() +{ // Copy Widget style but make normal same as hovered FocussedStyle = WidgetStyle; FocussedStyle.Normal = FocussedStyle.Hovered; - - return MyButton.ToSharedRef(); } void UFocusableButton::SlateHandleFocusReceived() diff --git a/Source/StevesUEHelpers/Private/StevesUI/FocusableCheckBox.cpp b/Source/StevesUEHelpers/Private/StevesUI/FocusableCheckBox.cpp index e9d5c15..8b7da26 100644 --- a/Source/StevesUEHelpers/Private/StevesUI/FocusableCheckBox.cpp +++ b/Source/StevesUEHelpers/Private/StevesUI/FocusableCheckBox.cpp @@ -24,14 +24,20 @@ TSharedRef UFocusableCheckBox::RebuildWidget() MyCheckbox->SetContent(GetContentSlot()->Content ? GetContentSlot()->Content->TakeWidget() : SNullWidget::NullWidget); } + RefreshFocussedStyle(); + + + return MyCheckbox.ToSharedRef(); + +} + +void UFocusableCheckBox::RefreshFocussedStyle_Implementation() +{ // Copy Widget style but make normal same as hovered FocussedStyle = WidgetStyle; FocussedStyle.UncheckedImage = FocussedStyle.UncheckedHoveredImage; FocussedStyle.CheckedImage = FocussedStyle.CheckedHoveredImage; FocussedStyle.UndeterminedImage = FocussedStyle.UndeterminedHoveredImage; - - return MyCheckbox.ToSharedRef(); - } void UFocusableCheckBox::SlateHandleFocusReceived() diff --git a/Source/StevesUEHelpers/Public/StevesUI/FocusableButton.h b/Source/StevesUEHelpers/Public/StevesUI/FocusableButton.h index 14a7070..181a008 100644 --- a/Source/StevesUEHelpers/Public/StevesUI/FocusableButton.h +++ b/Source/StevesUEHelpers/Public/StevesUI/FocusableButton.h @@ -51,4 +51,11 @@ protected: void SlateHandleUnhovered(); virtual TSharedRef RebuildWidget() override; + + + /// Update the focussed style based on changes made to the default widget style. + /// Call this if you make runtime changes to the base style of this button. + /// Needed because we can't override SetStyle + UFUNCTION(BlueprintCallable, BlueprintNativeEvent) + void RefreshFocussedStyle(); }; \ No newline at end of file diff --git a/Source/StevesUEHelpers/Public/StevesUI/FocusableCheckBox.h b/Source/StevesUEHelpers/Public/StevesUI/FocusableCheckBox.h index 509c349..db595c1 100644 --- a/Source/StevesUEHelpers/Public/StevesUI/FocusableCheckBox.h +++ b/Source/StevesUEHelpers/Public/StevesUI/FocusableCheckBox.h @@ -55,5 +55,14 @@ protected: void SlateHandleUnhovered(); virtual TSharedRef RebuildWidget() override; + +public: + + /// Update the focussed style based on changes made to the default widget style. + /// Call this if you make runtime changes to the base style of this checkbox. + /// Needed because we can't override SetStyle + UFUNCTION(BlueprintCallable, BlueprintNativeEvent) + void RefreshFocussedStyle(); + };