Fixed rounding up issue

This commit is contained in:
MrRobin
2023-10-28 23:18:17 +02:00
parent 8933ca8723
commit 83ae2d963b
6 changed files with 74 additions and 54 deletions

Binary file not shown.

Before

Width:  |  Height:  |  Size: 5.3 KiB

After

Width:  |  Height:  |  Size: 5.3 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 8.6 KiB

After

Width:  |  Height:  |  Size: 8.5 KiB

View File

@ -40,94 +40,106 @@ void FMyDateTimeDetailCustomization::CustomizeHeader(TSharedRef<IPropertyHandle>
{ {
PropertyHandle = StructPropertyHandle; PropertyHandle = StructPropertyHandle;
SAssignNew(YearEntryBox, SNumericEntryBox<int32>) SAssignNew(YearEntryBox, SNumericEntryBox<double>)
.AllowSpin(true) .AllowSpin(true)
.MinValue(1) .MinValue(1)
.MaxValue(9999) .MaxValue(9999)
.MinSliderValue(1) .MinSliderValue(1)
.MaxSliderValue(9999) .MaxSliderValue(9999)
.MinFractionalDigits(0)
.MaxFractionalDigits(0)
.Font(IDetailLayoutBuilder::GetDetailFont()) .Font(IDetailLayoutBuilder::GetDetailFont())
.Value(this, &FMyDateTimeDetailCustomization::OnGetValue, 3) .Value(this, &FMyDateTimeDetailCustomization::OnGetValue, 3)
.OnValueChanged(this, &FMyDateTimeDetailCustomization::OnValueChanged, 3) .OnValueChanged(this, &FMyDateTimeDetailCustomization::OnValueChanged, 3)
.OnValueCommitted(this, &FMyDateTimeDetailCustomization::OnValueCommitted, 3) .OnValueCommitted(this, &FMyDateTimeDetailCustomization::OnValueCommitted, 3)
.OnBeginSliderMovement(this, &FMyDateTimeDetailCustomization::OnBeginSliderMovement) .OnBeginSliderMovement(this, &FMyDateTimeDetailCustomization::OnBeginSliderMovement)
.OnEndSliderMovement(this, &FMyDateTimeDetailCustomization::OnEndSliderMovement) .OnEndSliderMovement(this, &FMyDateTimeDetailCustomization::OnEndSliderMovement)
.TypeInterface(MakeShareable(new TNumericUnitTypeInterface<int32>(EUnit::Years))) .TypeInterface(MakeShareable(new TNumericUnitTypeInterface<double>(EUnit::Years)))
.LinearDeltaSensitivity(1); .LinearDeltaSensitivity(1);
SAssignNew(MonthEntryBox, SNumericEntryBox<int32>) SAssignNew(MonthEntryBox, SNumericEntryBox<double>)
.AllowSpin(true) .AllowSpin(true)
.MinValue(1) .MinValue(1)
.MaxValue(12) .MaxValue(12)
.MinSliderValue(1) .MinSliderValue(1)
.MaxSliderValue(12) .MaxSliderValue(12)
.MinFractionalDigits(0)
.MaxFractionalDigits(0)
.Font(IDetailLayoutBuilder::GetDetailFont()) .Font(IDetailLayoutBuilder::GetDetailFont())
.Value(this, &FMyDateTimeDetailCustomization::OnGetValue, 4) .Value(this, &FMyDateTimeDetailCustomization::OnGetValue, 4)
.OnValueChanged(this, &FMyDateTimeDetailCustomization::OnValueChanged, 4) .OnValueChanged(this, &FMyDateTimeDetailCustomization::OnValueChanged, 4)
.OnValueCommitted(this, &FMyDateTimeDetailCustomization::OnValueCommitted, 4) .OnValueCommitted(this, &FMyDateTimeDetailCustomization::OnValueCommitted, 4)
.OnBeginSliderMovement(this, &FMyDateTimeDetailCustomization::OnBeginSliderMovement) .OnBeginSliderMovement(this, &FMyDateTimeDetailCustomization::OnBeginSliderMovement)
.OnEndSliderMovement(this, &FMyDateTimeDetailCustomization::OnEndSliderMovement) .OnEndSliderMovement(this, &FMyDateTimeDetailCustomization::OnEndSliderMovement)
.TypeInterface(MakeShareable(new TNumericUnitTypeInterface<int32>(EUnit::Months))) .TypeInterface(MakeShareable(new TNumericUnitTypeInterface<double>(EUnit::Months)))
.LinearDeltaSensitivity(1); .LinearDeltaSensitivity(1);
SAssignNew(DayEntryBox, SNumericEntryBox<int32>) SAssignNew(DayEntryBox, SNumericEntryBox<double>)
.AllowSpin(true) .AllowSpin(true)
.MinValue(1) .MinValue(1)
.MaxValue(31) .MaxValue(31)
.MinSliderValue(1) .MinSliderValue(1)
.MaxSliderValue(31) .MaxSliderValue(31)
.MinFractionalDigits(0)
.MaxFractionalDigits(0)
.Font(IDetailLayoutBuilder::GetDetailFont()) .Font(IDetailLayoutBuilder::GetDetailFont())
.Value(this, &FMyDateTimeDetailCustomization::OnGetValue, 5) .Value(this, &FMyDateTimeDetailCustomization::OnGetValue, 5)
.OnValueChanged(this, &FMyDateTimeDetailCustomization::OnValueChanged, 5) .OnValueChanged(this, &FMyDateTimeDetailCustomization::OnValueChanged, 5)
.OnValueCommitted(this, &FMyDateTimeDetailCustomization::OnValueCommitted, 5) .OnValueCommitted(this, &FMyDateTimeDetailCustomization::OnValueCommitted, 5)
.OnBeginSliderMovement(this, &FMyDateTimeDetailCustomization::OnBeginSliderMovement) .OnBeginSliderMovement(this, &FMyDateTimeDetailCustomization::OnBeginSliderMovement)
.OnEndSliderMovement(this, &FMyDateTimeDetailCustomization::OnEndSliderMovement) .OnEndSliderMovement(this, &FMyDateTimeDetailCustomization::OnEndSliderMovement)
.TypeInterface(MakeShareable(new TNumericUnitTypeInterface<int32>(EUnit::Days))) .TypeInterface(MakeShareable(new TNumericUnitTypeInterface<double>(EUnit::Days)))
.LinearDeltaSensitivity(1); .LinearDeltaSensitivity(1);
SAssignNew(HourEntryBox, SNumericEntryBox<int32>) SAssignNew(HourEntryBox, SNumericEntryBox<double>)
.AllowSpin(true) .AllowSpin(true)
.MinValue(0) .MinValue(0)
.MaxValue(23) .MaxValue(23)
.MinSliderValue(0) .MinSliderValue(0)
.MaxSliderValue(23) .MaxSliderValue(23)
.MinFractionalDigits(0)
.MaxFractionalDigits(0)
.Font(IDetailLayoutBuilder::GetDetailFont()) .Font(IDetailLayoutBuilder::GetDetailFont())
.Value(this, &FMyDateTimeDetailCustomization::OnGetValue, 0) .Value(this, &FMyDateTimeDetailCustomization::OnGetValue, 0)
.OnValueChanged(this, &FMyDateTimeDetailCustomization::OnValueChanged, 0) .OnValueChanged(this, &FMyDateTimeDetailCustomization::OnValueChanged, 0)
.OnValueCommitted(this, &FMyDateTimeDetailCustomization::OnValueCommitted, 0) .OnValueCommitted(this, &FMyDateTimeDetailCustomization::OnValueCommitted, 0)
.OnBeginSliderMovement(this, &FMyDateTimeDetailCustomization::OnBeginSliderMovement) .OnBeginSliderMovement(this, &FMyDateTimeDetailCustomization::OnBeginSliderMovement)
.OnEndSliderMovement(this, &FMyDateTimeDetailCustomization::OnEndSliderMovement) .OnEndSliderMovement(this, &FMyDateTimeDetailCustomization::OnEndSliderMovement)
.TypeInterface(MakeShareable(new TNumericUnitTypeInterface<int32>(EUnit::Hours))) .TypeInterface(MakeShareable(new TNumericUnitTypeInterface<double>(EUnit::Hours)))
.LinearDeltaSensitivity(1); .LinearDeltaSensitivity(1);
SAssignNew(MinuteEntryBox, SNumericEntryBox<int32>) SAssignNew(MinuteEntryBox, SNumericEntryBox<double>)
.AllowSpin(true) .AllowSpin(true)
.MinValue(0) .MinValue(0)
.MaxValue(59) .MaxValue(59)
.MinSliderValue(0) .MinSliderValue(0)
.MaxSliderValue(59) .MaxSliderValue(59)
.MinFractionalDigits(0)
.MaxFractionalDigits(0)
.Font(IDetailLayoutBuilder::GetDetailFont()) .Font(IDetailLayoutBuilder::GetDetailFont())
.Value(this, &FMyDateTimeDetailCustomization::OnGetValue, 1) .Value(this, &FMyDateTimeDetailCustomization::OnGetValue, 1)
.OnValueChanged(this, &FMyDateTimeDetailCustomization::OnValueChanged, 1) .OnValueChanged(this, &FMyDateTimeDetailCustomization::OnValueChanged, 1)
.OnValueCommitted(this, &FMyDateTimeDetailCustomization::OnValueCommitted, 1) .OnValueCommitted(this, &FMyDateTimeDetailCustomization::OnValueCommitted, 1)
.OnBeginSliderMovement(this, &FMyDateTimeDetailCustomization::OnBeginSliderMovement) .OnBeginSliderMovement(this, &FMyDateTimeDetailCustomization::OnBeginSliderMovement)
.OnEndSliderMovement(this, &FMyDateTimeDetailCustomization::OnEndSliderMovement) .OnEndSliderMovement(this, &FMyDateTimeDetailCustomization::OnEndSliderMovement)
.TypeInterface(MakeShareable(new TNumericUnitTypeInterface<int32>(EUnit::Minutes))) .TypeInterface(MakeShareable(new TNumericUnitTypeInterface<double>(EUnit::Minutes)))
.LinearDeltaSensitivity(1); .LinearDeltaSensitivity(1);
SAssignNew(SecondEntryBox, SNumericEntryBox<int32>) SAssignNew(SecondEntryBox, SNumericEntryBox<double>)
.AllowSpin(true) .AllowSpin(true)
.MinValue(0) .MinValue(0)
.MaxValue(59) .MaxValue(59)
.MinSliderValue(0) .MinSliderValue(0)
.MaxSliderValue(59) .MaxSliderValue(59)
.MinFractionalDigits(0)
.MaxFractionalDigits(0)
.Font(IDetailLayoutBuilder::GetDetailFont()) .Font(IDetailLayoutBuilder::GetDetailFont())
.Value(this, &FMyDateTimeDetailCustomization::OnGetValue, 2) .Value(this, &FMyDateTimeDetailCustomization::OnGetValue, 2)
.OnValueChanged(this, &FMyDateTimeDetailCustomization::OnValueChanged, 2) .OnValueChanged(this, &FMyDateTimeDetailCustomization::OnValueChanged, 2)
.OnValueCommitted(this, &FMyDateTimeDetailCustomization::OnValueCommitted, 2) .OnValueCommitted(this, &FMyDateTimeDetailCustomization::OnValueCommitted, 2)
.OnBeginSliderMovement(this, &FMyDateTimeDetailCustomization::OnBeginSliderMovement) .OnBeginSliderMovement(this, &FMyDateTimeDetailCustomization::OnBeginSliderMovement)
.OnEndSliderMovement(this, &FMyDateTimeDetailCustomization::OnEndSliderMovement) .OnEndSliderMovement(this, &FMyDateTimeDetailCustomization::OnEndSliderMovement)
.TypeInterface(MakeShareable(new TNumericUnitTypeInterface<int32>(EUnit::Seconds))) .TypeInterface(MakeShareable(new TNumericUnitTypeInterface<double>(EUnit::Seconds)))
.LinearDeltaSensitivity(1); .LinearDeltaSensitivity(1);
HeaderRow HeaderRow
@ -193,41 +205,41 @@ void FMyDateTimeDetailCustomization::CustomizeHeader(TSharedRef<IPropertyHandle>
/* FMyDateTimeDetailCustomization callbacks /* FMyDateTimeDetailCustomization callbacks
*****************************************************************************/ *****************************************************************************/
TOptional<int32> FMyDateTimeDetailCustomization::OnGetValue(int32 Index) const TOptional<double> FMyDateTimeDetailCustomization::OnGetValue(int32 Index) const
{ {
TArray<void*> RawData; TArray<void*> RawData;
PropertyHandle->AccessRawData(RawData); PropertyHandle->AccessRawData(RawData);
if (RawData.Num() != 1) if (RawData.Num() != 1)
return TOptional<int32>(); return TOptional<double>();
if (RawData[0] == nullptr) if (RawData[0] == nullptr)
return TOptional<int32>(); return TOptional<double>();
auto* DateTime = ((FDateTime*)RawData[0]); auto* DateTime = ((FDateTime*)RawData[0]);
switch (Index) switch (Index)
{ {
case 0: case 0:
return TOptional<int32>(DateTime->GetHour()); return TOptional<double>(DateTime->GetHour());
case 1: case 1:
return TOptional<int32>(DateTime->GetMinute()); return TOptional<double>(DateTime->GetMinute());
case 2: case 2:
return TOptional<int32>(DateTime->GetSecond()); return TOptional<double>(DateTime->GetSecond());
case 3: case 3:
return TOptional<int32>(DateTime->GetYear()); return TOptional<double>(DateTime->GetYear());
case 4: case 4:
return TOptional<int32>(DateTime->GetMonth()); return TOptional<double>(DateTime->GetMonth());
case 5: case 5:
return TOptional<int32>(DateTime->GetDay()); return TOptional<double>(DateTime->GetDay());
default: default:
return TOptional<int32>(); return TOptional<double>();
} }
} }
@ -242,15 +254,17 @@ void FMyDateTimeDetailCustomization::OnBeginSliderMovement()
); );
} }
void FMyDateTimeDetailCustomization::OnEndSliderMovement(int32 NewValue) void FMyDateTimeDetailCustomization::OnEndSliderMovement(double NewValue)
{ {
bIsUsingSlider = false; bIsUsingSlider = false;
GEditor->EndTransaction(); GEditor->EndTransaction();
} }
void FMyDateTimeDetailCustomization::OnValueCommitted(int32 NewValue, ETextCommit::Type CommitType, int32 Index) void FMyDateTimeDetailCustomization::OnValueCommitted(double NewValue, ETextCommit::Type CommitType, int32 Index)
{ {
NewValue = FMath::CeilToDouble(NewValue);
TArray<void*> RawData; TArray<void*> RawData;
PropertyHandle->AccessRawData(RawData); PropertyHandle->AccessRawData(RawData);
@ -311,11 +325,13 @@ void FMyDateTimeDetailCustomization::OnValueCommitted(int32 NewValue, ETextCommi
PropertyHandle->NotifyFinishedChangingProperties(); PropertyHandle->NotifyFinishedChangingProperties();
} }
void FMyDateTimeDetailCustomization::OnValueChanged(int32 NewValue, int32 Index) void FMyDateTimeDetailCustomization::OnValueChanged(double NewValue, int32 Index)
{ {
if (!bIsUsingSlider) if (!bIsUsingSlider)
return; return;
NewValue = FMath::CeilToDouble(NewValue);
TArray<void*> RawData; TArray<void*> RawData;
PropertyHandle->AccessRawData(RawData); PropertyHandle->AccessRawData(RawData);
@ -374,9 +390,6 @@ void FMyDateTimeDetailCustomization::OnValueChanged(int32 NewValue, int32 Index)
PropertyHandle->NotifyPostChange(EPropertyChangeType::ValueSet); PropertyHandle->NotifyPostChange(EPropertyChangeType::ValueSet);
PropertyHandle->NotifyFinishedChangingProperties(); PropertyHandle->NotifyFinishedChangingProperties();
//EPropertyValueSetFlags::Type Flags = EPropertyValueSetFlags::InteractiveChange;
//PropertyHandle->SetValue(NewValue, Flags);
} }
#undef LOCTEXT_NAMESPACE #undef LOCTEXT_NAMESPACE

View File

@ -44,49 +44,55 @@ void FMyTimespanDetailCustomization::CustomizeHeader(
{ {
PropertyHandle = StructPropertyHandle; PropertyHandle = StructPropertyHandle;
SAssignNew(HourEntryBox, SNumericEntryBox<int32>) SAssignNew(HourEntryBox, SNumericEntryBox<double>)
.AllowSpin(true) .AllowSpin(true)
.MinValue(0) .MinValue(0)
.MaxValue(23) .MaxValue(23)
.MinSliderValue(0) .MinSliderValue(0)
.MaxSliderValue(23) .MaxSliderValue(23)
.MinFractionalDigits(0)
.MaxFractionalDigits(0)
.Font(IDetailLayoutBuilder::GetDetailFont()) .Font(IDetailLayoutBuilder::GetDetailFont())
.Value(this, &FMyTimespanDetailCustomization::OnGetValue, 0) .Value(this, &FMyTimespanDetailCustomization::OnGetValue, 0)
.OnValueChanged(this, &FMyTimespanDetailCustomization::OnValueChanged, 0) .OnValueChanged(this, &FMyTimespanDetailCustomization::OnValueChanged, 0)
.OnValueCommitted(this, &FMyTimespanDetailCustomization::OnValueCommitted, 0) .OnValueCommitted(this, &FMyTimespanDetailCustomization::OnValueCommitted, 0)
.OnBeginSliderMovement(this, &FMyTimespanDetailCustomization::OnBeginSliderMovement) .OnBeginSliderMovement(this, &FMyTimespanDetailCustomization::OnBeginSliderMovement)
.OnEndSliderMovement(this, &FMyTimespanDetailCustomization::OnEndSliderMovement) .OnEndSliderMovement(this, &FMyTimespanDetailCustomization::OnEndSliderMovement)
.TypeInterface(MakeShareable(new TNumericUnitTypeInterface<int32>(EUnit::Hours))) .TypeInterface(MakeShareable(new TNumericUnitTypeInterface<double>(EUnit::Hours)))
.LinearDeltaSensitivity(1); .LinearDeltaSensitivity(1);
SAssignNew(MinuteEntryBox, SNumericEntryBox<int32>) SAssignNew(MinuteEntryBox, SNumericEntryBox<double>)
.AllowSpin(true) .AllowSpin(true)
.MinValue(0) .MinValue(0)
.MaxValue(59) .MaxValue(59)
.MinSliderValue(0) .MinSliderValue(0)
.MaxSliderValue(59) .MaxSliderValue(59)
.MinFractionalDigits(0)
.MaxFractionalDigits(0)
.Font(IDetailLayoutBuilder::GetDetailFont()) .Font(IDetailLayoutBuilder::GetDetailFont())
.Value(this, &FMyTimespanDetailCustomization::OnGetValue, 1) .Value(this, &FMyTimespanDetailCustomization::OnGetValue, 1)
.OnValueChanged(this, &FMyTimespanDetailCustomization::OnValueChanged, 1) .OnValueChanged(this, &FMyTimespanDetailCustomization::OnValueChanged, 1)
.OnValueCommitted(this, &FMyTimespanDetailCustomization::OnValueCommitted, 1) .OnValueCommitted(this, &FMyTimespanDetailCustomization::OnValueCommitted, 1)
.OnBeginSliderMovement(this, &FMyTimespanDetailCustomization::OnBeginSliderMovement) .OnBeginSliderMovement(this, &FMyTimespanDetailCustomization::OnBeginSliderMovement)
.OnEndSliderMovement(this, &FMyTimespanDetailCustomization::OnEndSliderMovement) .OnEndSliderMovement(this, &FMyTimespanDetailCustomization::OnEndSliderMovement)
.TypeInterface(MakeShareable(new TNumericUnitTypeInterface<int32>(EUnit::Minutes))) .TypeInterface(MakeShareable(new TNumericUnitTypeInterface<double>(EUnit::Minutes)))
.LinearDeltaSensitivity(1); .LinearDeltaSensitivity(1);
SAssignNew(SecondEntryBox, SNumericEntryBox<int32>) SAssignNew(SecondEntryBox, SNumericEntryBox<double>)
.AllowSpin(true) .AllowSpin(true)
.MinValue(0) .MinValue(0)
.MaxValue(59) .MaxValue(59)
.MinSliderValue(0) .MinSliderValue(0)
.MaxSliderValue(59) .MaxSliderValue(59)
.MinFractionalDigits(0)
.MaxFractionalDigits(0)
.Font(IDetailLayoutBuilder::GetDetailFont()) .Font(IDetailLayoutBuilder::GetDetailFont())
.Value(this, &FMyTimespanDetailCustomization::OnGetValue, 2) .Value(this, &FMyTimespanDetailCustomization::OnGetValue, 2)
.OnValueChanged(this, &FMyTimespanDetailCustomization::OnValueChanged, 2) .OnValueChanged(this, &FMyTimespanDetailCustomization::OnValueChanged, 2)
.OnValueCommitted(this, &FMyTimespanDetailCustomization::OnValueCommitted, 2) .OnValueCommitted(this, &FMyTimespanDetailCustomization::OnValueCommitted, 2)
.OnBeginSliderMovement(this, &FMyTimespanDetailCustomization::OnBeginSliderMovement) .OnBeginSliderMovement(this, &FMyTimespanDetailCustomization::OnBeginSliderMovement)
.OnEndSliderMovement(this, &FMyTimespanDetailCustomization::OnEndSliderMovement) .OnEndSliderMovement(this, &FMyTimespanDetailCustomization::OnEndSliderMovement)
.TypeInterface(MakeShareable(new TNumericUnitTypeInterface<int32>(EUnit::Seconds))) .TypeInterface(MakeShareable(new TNumericUnitTypeInterface<double>(EUnit::Seconds)))
.LinearDeltaSensitivity(1); .LinearDeltaSensitivity(1);
HeaderRow HeaderRow
@ -121,32 +127,32 @@ void FMyTimespanDetailCustomization::CustomizeHeader(
/* FMyTimespanDetailCustomization callbacks /* FMyTimespanDetailCustomization callbacks
*****************************************************************************/ *****************************************************************************/
TOptional<int32> FMyTimespanDetailCustomization::OnGetValue(int32 Index) const TOptional<double> FMyTimespanDetailCustomization::OnGetValue(int32 Index) const
{ {
TArray<void*> RawData; TArray<void*> RawData;
PropertyHandle->AccessRawData(RawData); PropertyHandle->AccessRawData(RawData);
if (RawData.Num() != 1) if (RawData.Num() != 1)
return TOptional<int32>(); return TOptional<double>();
if (RawData[0] == nullptr) if (RawData[0] == nullptr)
return TOptional<int32>(); return TOptional<double>();
auto* Timespan = ((FTimespan*)RawData[0]); auto* Timespan = ((FTimespan*)RawData[0]);
switch (Index) switch (Index)
{ {
case 0: case 0:
return TOptional<int32>(Timespan->GetHours()); return TOptional<double>(Timespan->GetHours());
case 1: case 1:
return TOptional<int32>(Timespan->GetMinutes()); return TOptional<double>(Timespan->GetMinutes());
case 2: case 2:
return TOptional<int32>(Timespan->GetSeconds()); return TOptional<double>(Timespan->GetSeconds());
default: default:
return TOptional<int32>(); return TOptional<double>();
} }
} }
@ -157,15 +163,17 @@ void FMyTimespanDetailCustomization::OnBeginSliderMovement()
GEditor->BeginTransaction(FText::Format(NSLOCTEXT("MyTimespanDetailCustomization", "SetTimespanProperty", "Edit {0}"), PropertyHandle->GetPropertyDisplayName())); GEditor->BeginTransaction(FText::Format(NSLOCTEXT("MyTimespanDetailCustomization", "SetTimespanProperty", "Edit {0}"), PropertyHandle->GetPropertyDisplayName()));
} }
void FMyTimespanDetailCustomization::OnEndSliderMovement(int32 NewValue) void FMyTimespanDetailCustomization::OnEndSliderMovement(double NewValue)
{ {
bIsUsingSlider = false; bIsUsingSlider = false;
GEditor->EndTransaction(); GEditor->EndTransaction();
} }
void FMyTimespanDetailCustomization::OnValueCommitted(int32 NewValue, ETextCommit::Type CommitType, int32 Index) void FMyTimespanDetailCustomization::OnValueCommitted(double NewValue, ETextCommit::Type CommitType, int32 Index)
{ {
NewValue = FMath::CeilToDouble(NewValue);
TArray<void*> RawData; TArray<void*> RawData;
PropertyHandle->AccessRawData(RawData); PropertyHandle->AccessRawData(RawData);
@ -202,13 +210,12 @@ void FMyTimespanDetailCustomization::OnValueCommitted(int32 NewValue, ETextCommi
PropertyHandle->NotifyFinishedChangingProperties(); PropertyHandle->NotifyFinishedChangingProperties();
} }
void FMyTimespanDetailCustomization::OnValueChanged(int32 NewValue, int32 Index) void FMyTimespanDetailCustomization::OnValueChanged(double NewValue, int32 Index)
{ {
if (!bIsUsingSlider) if (!bIsUsingSlider)
return; return;
//EPropertyValueSetFlags::Type Flags = EPropertyValueSetFlags::InteractiveChange; NewValue = FMath::CeilToDouble(NewValue);
//PropertyHandle->SetValue(NewValue, Flags);
TArray<void*> RawData; TArray<void*> RawData;

View File

@ -36,11 +36,11 @@ public:
void CustomizeHeader(TSharedRef<class IPropertyHandle> StructPropertyHandle, class FDetailWidgetRow& HeaderRow, IPropertyTypeCustomizationUtils& StructCustomizationUtils) override; void CustomizeHeader(TSharedRef<class IPropertyHandle> StructPropertyHandle, class FDetailWidgetRow& HeaderRow, IPropertyTypeCustomizationUtils& StructCustomizationUtils) override;
private: private:
TOptional<int32> OnGetValue(int32 Index) const; TOptional<double> OnGetValue(int32 Index) const;
void OnValueCommitted(int32 NewValue, ETextCommit::Type CommitType, int32 Index); void OnValueCommitted(double NewValue, ETextCommit::Type CommitType, int32 Index);
void OnValueChanged(int32 NewValue, int32 Index); void OnValueChanged(double NewValue, int32 Index);
void OnBeginSliderMovement(); void OnBeginSliderMovement();
void OnEndSliderMovement(int32 NewValue); void OnEndSliderMovement(double NewValue);
private: private:
/** Holds a handle to the property being edited. */ /** Holds a handle to the property being edited. */

View File

@ -35,11 +35,11 @@ public:
void CustomizeHeader(TSharedRef<class IPropertyHandle> StructPropertyHandle, class FDetailWidgetRow& HeaderRow, IPropertyTypeCustomizationUtils& StructCustomizationUtils) override; void CustomizeHeader(TSharedRef<class IPropertyHandle> StructPropertyHandle, class FDetailWidgetRow& HeaderRow, IPropertyTypeCustomizationUtils& StructCustomizationUtils) override;
private: private:
TOptional<int32> OnGetValue(int32 Index) const; TOptional<double> OnGetValue(int32 Index) const;
void OnValueCommitted(int32 NewValue, ETextCommit::Type CommitType, int32 Index); void OnValueCommitted(double NewValue, ETextCommit::Type CommitType, int32 Index);
void OnValueChanged(int32 NewValue, int32 Index); void OnValueChanged(double NewValue, int32 Index);
void OnBeginSliderMovement(); void OnBeginSliderMovement();
void OnEndSliderMovement(int32 NewValue); void OnEndSliderMovement(double NewValue);
private: private:
/** Holds a handle to the property being edited. */ /** Holds a handle to the property being edited. */