I want to make a calculator that people can enter numbers into 3 separate editable text boxes, these numbers are added together and displayed in a separate text box.
So far I have created the widget and can display numbers into the text boxes with declared variables.
I am struggling with getting the values from the editable text box, parsing these into int values and displaying this value in a separate text box.
Any suggestions or links to similar solutions would be greatly appreciated!
.h
UPROPERTY(meta = (BindWidget))
class UEditableTextBox* EditText1;
UPROPERTY(meta = (BindWidget))
class UTextBlock* SumNumTxt;
UPROPERTY(meta = (BindWidget))
class UTextBlock* AnsNumTxt;
void CalculateSum();
.cpp
SumBtn->OnClicked.AddUniqueDynamic(this, &URndWidget::OnSumClicked);
void URndWidget::OnSumClicked(const FText& Text) {
CalculateSum();
}
void URndWidget::CalculateSum() {
sum = num1 + num2 + num3;
SumNumTxt->SetText(FText::AsNumber(sum));
Text = EditText1->GetText();
AnsNumText->SetText(Text);
}