this was probably a bad idea because they need to be actors for events to work

This commit is contained in:
wonkyhonky2024
2025-05-09 23:18:45 +01:00
parent 8e1b4928a9
commit 916d188d5b
4 changed files with 38 additions and 6 deletions

View File

@ -15,4 +15,9 @@ 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();
}
void UMagicFloatInput::HandleMagicFloatsMangledEvent() {
OnMagicFloatsMangled.ExecuteIfBound();
} }

View File

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

View File

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

View File

@ -4,14 +4,24 @@
#include "CoreMinimal.h" #include "CoreMinimal.h"
#include "Components/TextBlock.h" #include "Components/TextBlock.h"
#include "MagicFloatInput.h"
#include "VerifierTextBlock.generated.h" #include "VerifierTextBlock.generated.h"
/** /**
* *
*/ */
UCLASS() UCLASS()
class MYPROJECT_API UVerifierTextBlock : public UTextBlock class MYPROJECT_API UVerifierTextBlock : public UTextBlock {
{
GENERATED_BODY()
GENERATED_BODY()
UPROPERTY(EditAnywhere)
UTextBlock * sourceInput;
UPROPERTY(EditAnywhere)
UMagicFloatInput * destInput;
void verifyFloats();
void BeginPlay() override;
}; };