working float verification

This commit is contained in:
wonkyhonky2024
2025-05-10 13:11:00 +01:00
parent 916d188d5b
commit 2c987be672
5 changed files with 9 additions and 53 deletions

BIN
Content/LinacLab/MyMyUserWidget.uasset (Stored with Git LFS)

Binary file not shown.

View File

@ -15,9 +15,11 @@ void UMagicFloatInput::HandleOnTextCommitted(
x = FCString::Atod(*inText.ToString()); x = FCString::Atod(*inText.ToString());
SetText(FText::FromString(FString::Printf(TEXT("%.7f"), x))); SetText(FText::FromString(FString::Printf(TEXT("%.7f"), x)));
HandleMagicFloatsMangledEvent(); if (myVerifier != nullptr) {
} if (sourceInput->GetText().EqualTo(GetText())) {
myVerifier->SetText(FText::FromString("VERIFIED"));
void UMagicFloatInput::HandleMagicFloatsMangledEvent() { } else {
OnMagicFloatsMangled.ExecuteIfBound(); myVerifier->SetText(FText());
}
}
} }

View File

@ -1,12 +0,0 @@
// Fill out your copyright notice in the Description page of Project Settings.
#include "VerifierTextBlock.h"
void UVerifierTextBlock::NativeOnInitialized() {
if (destInput != nullptr) {
destInput->OnMagicFloatsMangled.BindUObject(
this,
&UVerifierTextBlock::verifyFloats
);
}
}

View File

@ -7,8 +7,6 @@
#include <Components/TextBlock.h> #include <Components/TextBlock.h>
#include "MagicFloatInput.generated.h" #include "MagicFloatInput.generated.h"
DECLARE_DELEGATE(FOnMagicFloatsMangledDelegate);
/** /**
* *
*/ */
@ -27,9 +25,4 @@ class MYPROJECT_API UMagicFloatInput : public UEditableTextBox {
UPROPERTY(EditAnywhere) UPROPERTY(EditAnywhere)
UTextBlock * myVerifier; UTextBlock * myVerifier;
UFUNCTION()
void HandleMagicFloatsMangledEvent();
FOnMagicFloatsMangledDelegate OnMagicFloatsMangled;
}; };

View File

@ -1,27 +0,0 @@
// Fill out your copyright notice in the Description page of Project Settings.
#pragma once
#include "CoreMinimal.h"
#include "Components/TextBlock.h"
#include "MagicFloatInput.h"
#include "VerifierTextBlock.generated.h"
/**
*
*/
UCLASS()
class MYPROJECT_API UVerifierTextBlock : public UTextBlock {
GENERATED_BODY()
UPROPERTY(EditAnywhere)
UTextBlock * sourceInput;
UPROPERTY(EditAnywhere)
UMagicFloatInput * destInput;
void verifyFloats();
void BeginPlay() override;
};