diff --git a/.gitignore b/.gitignore index f4334a5..94e73bc 100644 --- a/.gitignore +++ b/.gitignore @@ -11,4 +11,5 @@ Saved *.sln *.suo *.xcodeproj -*.xcworkspace \ No newline at end of file +*.xcworkspace +.cache \ No newline at end of file diff --git a/Source/MyProject/Private/MagicFloatInput.cpp b/Source/MyProject/Private/MagicFloatInput.cpp index 5e4f32f..0b21fed 100644 --- a/Source/MyProject/Private/MagicFloatInput.cpp +++ b/Source/MyProject/Private/MagicFloatInput.cpp @@ -3,4 +3,16 @@ #include "MagicFloatInput.h" -void UMagicFloatInput::HandleOnTextCommitted(const FText& inText, ETextCommit::Type inCommitMethod) {} \ No newline at end of file +void UMagicFloatInput::HandleOnTextCommitted(const FText& inText, ETextCommit::Type inCommitMethod) { + if(inText.IsEmptyOrWhitespace()) { + if(sourceInput != nullptr) { + SetText(sourceInput->GetText()); + } + } + else { + auto x = FCString::Atof(*inText.ToString()); + SetText(FText::FromString(FString::Printf(TEXT("%.7f"),x))); + + } + +} \ No newline at end of file diff --git a/Source/MyProject/Public/MagicFloatInput.h b/Source/MyProject/Public/MagicFloatInput.h index fe7349f..e01090d 100644 --- a/Source/MyProject/Public/MagicFloatInput.h +++ b/Source/MyProject/Public/MagicFloatInput.h @@ -15,4 +15,7 @@ class MYPROJECT_API UMagicFloatInput : public UEditableTextBox GENERATED_BODY() void HandleOnTextCommitted(const FText& Text, ETextCommit::Type CommitMethod) override; + + UPROPERTY(EditAnywhere) + UEditableTextBox * sourceInput; }; diff --git a/compile_commands.json b/compile_commands.json new file mode 120000 index 0000000..9983257 --- /dev/null +++ b/compile_commands.json @@ -0,0 +1 @@ +.vscode/compileCommands_MyProject.json \ No newline at end of file