5.0 compat

This commit is contained in:
Steve Streeting 2023-01-09 12:45:18 +00:00
parent cc6eea4862
commit cb8a830d54

View File

@ -6,11 +6,18 @@ TSharedRef<SWidget> UFocusableCheckBox::RebuildWidget()
{ {
MyCheckbox = SNew(SFocusableCheckBox) MyCheckbox = SNew(SFocusableCheckBox)
.OnCheckStateChanged( BIND_UOBJECT_DELEGATE(FOnCheckStateChanged, SlateOnCheckStateChangedCallback) ) .OnCheckStateChanged( BIND_UOBJECT_DELEGATE(FOnCheckStateChanged, SlateOnCheckStateChangedCallback) )
#if ENGINE_MAJOR_VERSION == 5 && ENGINE_MINOR_VERSION > 0
.Style(&GetWidgetStyle()) .Style(&GetWidgetStyle())
.HAlign( HorizontalAlignment )
.ClickMethod(GetClickMethod()) .ClickMethod(GetClickMethod())
.TouchMethod(GetTouchMethod()) .TouchMethod(GetTouchMethod())
.PressMethod(GetPressMethod()) .PressMethod(GetPressMethod())
#else
.Style(&WidgetStyle)
.ClickMethod(ClickMethod)
.TouchMethod(TouchMethod)
.PressMethod(PressMethod)
#endif
.HAlign( HorizontalAlignment )
.IsFocusable(IsFocusable) .IsFocusable(IsFocusable)
// Our new events // Our new events
.OnHovered(BIND_UOBJECT_DELEGATE(FSimpleDelegate, SlateHandleHovered)) .OnHovered(BIND_UOBJECT_DELEGATE(FSimpleDelegate, SlateHandleHovered))
@ -34,7 +41,11 @@ TSharedRef<SWidget> UFocusableCheckBox::RebuildWidget()
void UFocusableCheckBox::RefreshFocussedStyle_Implementation() void UFocusableCheckBox::RefreshFocussedStyle_Implementation()
{ {
// Copy Widget style but make normal same as hovered // Copy Widget style but make normal same as hovered
#if ENGINE_MAJOR_VERSION == 5 && ENGINE_MINOR_VERSION > 0
FocussedStyle = GetWidgetStyle(); FocussedStyle = GetWidgetStyle();
#else
FocussedStyle = WidgetStyle;
#endif
FocussedStyle.UncheckedImage = FocussedStyle.UncheckedHoveredImage; FocussedStyle.UncheckedImage = FocussedStyle.UncheckedHoveredImage;
FocussedStyle.CheckedImage = FocussedStyle.CheckedHoveredImage; FocussedStyle.CheckedImage = FocussedStyle.CheckedHoveredImage;
FocussedStyle.UndeterminedImage = FocussedStyle.UndeterminedHoveredImage; FocussedStyle.UndeterminedImage = FocussedStyle.UndeterminedHoveredImage;
@ -65,7 +76,11 @@ void UFocusableCheckBox::UndoFocusStyle()
{ {
if (MyCheckbox.IsValid()) if (MyCheckbox.IsValid())
{ {
#if ENGINE_MAJOR_VERSION == 5 && ENGINE_MINOR_VERSION > 0
MyCheckbox->SetStyle(&GetWidgetStyle()); MyCheckbox->SetStyle(&GetWidgetStyle());
#else
MyCheckbox->SetStyle(&WidgetStyle);
#endif
} }
} }