mirror of
https://github.com/sinbad/StevesUEHelpers.git
synced 2025-02-23 17:45:23 +00:00
Add RefreshFocussedStyle method to allow runtime changes to widget style
This commit is contained in:
parent
51a57c35ef
commit
05a1c1ab46
@ -31,11 +31,16 @@ TSharedRef<SWidget> UFocusableButton::RebuildWidget()
|
|||||||
Cast<UButtonSlot>(GetContentSlot())->BuildSlot(MyButton.ToSharedRef());
|
Cast<UButtonSlot>(GetContentSlot())->BuildSlot(MyButton.ToSharedRef());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
RefreshFocussedStyle();
|
||||||
|
|
||||||
|
return MyButton.ToSharedRef();
|
||||||
|
}
|
||||||
|
|
||||||
|
void UFocusableButton::RefreshFocussedStyle_Implementation()
|
||||||
|
{
|
||||||
// Copy Widget style but make normal same as hovered
|
// Copy Widget style but make normal same as hovered
|
||||||
FocussedStyle = WidgetStyle;
|
FocussedStyle = WidgetStyle;
|
||||||
FocussedStyle.Normal = FocussedStyle.Hovered;
|
FocussedStyle.Normal = FocussedStyle.Hovered;
|
||||||
|
|
||||||
return MyButton.ToSharedRef();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void UFocusableButton::SlateHandleFocusReceived()
|
void UFocusableButton::SlateHandleFocusReceived()
|
||||||
|
@ -24,14 +24,20 @@ TSharedRef<SWidget> UFocusableCheckBox::RebuildWidget()
|
|||||||
MyCheckbox->SetContent(GetContentSlot()->Content ? GetContentSlot()->Content->TakeWidget() : SNullWidget::NullWidget);
|
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
|
// Copy Widget style but make normal same as hovered
|
||||||
FocussedStyle = WidgetStyle;
|
FocussedStyle = WidgetStyle;
|
||||||
FocussedStyle.UncheckedImage = FocussedStyle.UncheckedHoveredImage;
|
FocussedStyle.UncheckedImage = FocussedStyle.UncheckedHoveredImage;
|
||||||
FocussedStyle.CheckedImage = FocussedStyle.CheckedHoveredImage;
|
FocussedStyle.CheckedImage = FocussedStyle.CheckedHoveredImage;
|
||||||
FocussedStyle.UndeterminedImage = FocussedStyle.UndeterminedHoveredImage;
|
FocussedStyle.UndeterminedImage = FocussedStyle.UndeterminedHoveredImage;
|
||||||
|
|
||||||
return MyCheckbox.ToSharedRef();
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void UFocusableCheckBox::SlateHandleFocusReceived()
|
void UFocusableCheckBox::SlateHandleFocusReceived()
|
||||||
|
@ -51,4 +51,11 @@ protected:
|
|||||||
void SlateHandleUnhovered();
|
void SlateHandleUnhovered();
|
||||||
|
|
||||||
virtual TSharedRef<SWidget> RebuildWidget() override;
|
virtual TSharedRef<SWidget> 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();
|
||||||
};
|
};
|
@ -55,5 +55,14 @@ protected:
|
|||||||
void SlateHandleUnhovered();
|
void SlateHandleUnhovered();
|
||||||
|
|
||||||
virtual TSharedRef<SWidget> RebuildWidget() override;
|
virtual TSharedRef<SWidget> 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();
|
||||||
|
|
||||||
|
|
||||||
};
|
};
|
||||||
|
Loading…
x
Reference in New Issue
Block a user