this was probably a bad idea because they need to be actors for events to work
This commit is contained in:
@ -15,4 +15,9 @@ void UMagicFloatInput::HandleOnTextCommitted(
|
||||
x = FCString::Atod(*inText.ToString());
|
||||
|
||||
SetText(FText::FromString(FString::Printf(TEXT("%.7f"), x)));
|
||||
HandleMagicFloatsMangledEvent();
|
||||
}
|
||||
|
||||
void UMagicFloatInput::HandleMagicFloatsMangledEvent() {
|
||||
OnMagicFloatsMangled.ExecuteIfBound();
|
||||
}
|
||||
|
@ -1,5 +1,12 @@
|
||||
// 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
|
||||
);
|
||||
}
|
||||
}
|
||||
|
@ -7,6 +7,8 @@
|
||||
#include <Components/TextBlock.h>
|
||||
#include "MagicFloatInput.generated.h"
|
||||
|
||||
DECLARE_DELEGATE(FOnMagicFloatsMangledDelegate);
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
@ -22,4 +24,12 @@ class MYPROJECT_API UMagicFloatInput : public UEditableTextBox {
|
||||
|
||||
UPROPERTY(EditAnywhere)
|
||||
UTextBlock * sourceInput;
|
||||
|
||||
UPROPERTY(EditAnywhere)
|
||||
UTextBlock * myVerifier;
|
||||
|
||||
UFUNCTION()
|
||||
void HandleMagicFloatsMangledEvent();
|
||||
|
||||
FOnMagicFloatsMangledDelegate OnMagicFloatsMangled;
|
||||
};
|
||||
|
@ -4,14 +4,24 @@
|
||||
|
||||
#include "CoreMinimal.h"
|
||||
#include "Components/TextBlock.h"
|
||||
#include "MagicFloatInput.h"
|
||||
#include "VerifierTextBlock.generated.h"
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
UCLASS()
|
||||
class MYPROJECT_API UVerifierTextBlock : public UTextBlock
|
||||
{
|
||||
class MYPROJECT_API UVerifierTextBlock : public UTextBlock {
|
||||
|
||||
GENERATED_BODY()
|
||||
|
||||
UPROPERTY(EditAnywhere)
|
||||
UTextBlock * sourceInput;
|
||||
|
||||
UPROPERTY(EditAnywhere)
|
||||
UMagicFloatInput * destInput;
|
||||
|
||||
void verifyFloats();
|
||||
|
||||
void BeginPlay() override;
|
||||
};
|
||||
|
Reference in New Issue
Block a user