diff --git a/Content/LinacLab/MyMyUserWidget.uasset b/Content/LinacLab/MyMyUserWidget.uasset index cb3c9c9..58eee89 100644 --- a/Content/LinacLab/MyMyUserWidget.uasset +++ b/Content/LinacLab/MyMyUserWidget.uasset @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:e257a3affe17951889e6d12766d297c265f3eb3c63710d161ca47bc53d965a5e -size 155176 +oid sha256:89749a6197f68a9d4359c02ac90d7551ecddb4b5f9327e78b88768e1ecdbb3f9 +size 205349 diff --git a/Content/LinacLab/vt100_Blueprint.uasset b/Content/LinacLab/vt100_Blueprint.uasset index f542db2..6be3f73 100644 --- a/Content/LinacLab/vt100_Blueprint.uasset +++ b/Content/LinacLab/vt100_Blueprint.uasset @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:f3976d74dfef952698b52743094d7e831ed889a198d49aa1f9ebfa4dc88b0445 -size 234024 +oid sha256:feb1403011a24b95c18c689369e93ae3e559adeabc5090dcdd4667b31a0d09fb +size 269267 diff --git a/Source/MyProject/Private/MagicFloatInput.cpp b/Source/MyProject/Private/MagicFloatInput.cpp index d0c4f04..6965452 100644 --- a/Source/MyProject/Private/MagicFloatInput.cpp +++ b/Source/MyProject/Private/MagicFloatInput.cpp @@ -6,15 +6,25 @@ void UMagicFloatInput::HandleOnTextCommitted( FText const & inText, ETextCommit::Type inCommitMethod ) { - double x = 0.0; - if (inText.IsEmptyOrWhitespace()) { - if (sourceInput != nullptr) { - x = FCString::Atod(*sourceInput->GetText().ToString()); - } - } else - x = FCString::Atod(*inText.ToString()); + if (inCommitMethod == ETextCommit::OnEnter) { - SetText(FText::FromString(FString::Printf(TEXT("%.7f"), x))); + double x = 0.0; + if (inText.IsEmptyOrWhitespace()) { + if (sourceInput != nullptr) { + x = FCString::Atod(*sourceInput->GetText().ToString()); + } + } else + x = FCString::Atod(*inText.ToString()); + + SetText(FText::FromString(FString::Printf(TEXT("%.7f"), x))); + if (next != nullptr) { + next->SetFocus(); + next->SetKeyboardFocus(); + } else if (cmdInput != nullptr) { + cmdInput->SetFocus(); + cmdInput->SetKeyboardFocus(); + } + } if (myVerifier != nullptr) { if (sourceInput->GetText().EqualTo(GetText())) { myVerifier->SetText(FText::FromString("VERIFIED")); diff --git a/Source/MyProject/Private/ModeInputTextBox.cpp b/Source/MyProject/Private/ModeInputTextBox.cpp index 5bbd372..fb2178f 100644 --- a/Source/MyProject/Private/ModeInputTextBox.cpp +++ b/Source/MyProject/Private/ModeInputTextBox.cpp @@ -4,7 +4,13 @@ #include void UModeInputTextBox::HandleOnTextChanged(FText const & inText) { - Text = Text.GetEmpty(); + /* + if (GetText().IsEmpty()) { + return; + } + SetText(FText()); + */ + Text = FText(); auto & s = inText.ToString(); // UE_LOGFMT(LogTemp, Warning, "kill me {inText}", s); diff --git a/Source/MyProject/Private/MyUserWidget.cpp b/Source/MyProject/Private/MyUserWidget.cpp index 1756af7..c1045bd 100644 --- a/Source/MyProject/Private/MyUserWidget.cpp +++ b/Source/MyProject/Private/MyUserWidget.cpp @@ -23,6 +23,7 @@ bool UMyUserWidget::AllVerified() { } void UMyUserWidget::NativeOnInitialized() { + // commandInput->SetClearKeyboardFocusOnCommit(false); auto ps = StaticCast(GetOwningPlayerState()); if (ps == nullptr) return; diff --git a/Source/MyProject/Public/MagicFloatInput.h b/Source/MyProject/Public/MagicFloatInput.h index b72c5d2..3829ecd 100644 --- a/Source/MyProject/Public/MagicFloatInput.h +++ b/Source/MyProject/Public/MagicFloatInput.h @@ -5,6 +5,7 @@ #include "Components/EditableTextBox.h" #include "CoreMinimal.h" #include +#include #include "MagicFloatInput.generated.h" /** @@ -15,14 +16,18 @@ class MYPROJECT_API UMagicFloatInput : public UEditableTextBox { GENERATED_BODY() - void HandleOnTextCommitted( - FText const & Text, - ETextCommit::Type CommitMethod - ) override; + void HandleOnTextCommitted(FText const & Text, ETextCommit::Type CommitMethod) + override; UPROPERTY(EditAnywhere) UTextBlock * sourceInput; UPROPERTY(EditAnywhere) UTextBlock * myVerifier; + + UPROPERTY(EditAnywhere) + UMagicFloatInput * next; + + UPROPERTY(EditAnywhere) + UModeInputTextBox * cmdInput; }; diff --git a/Source/MyProject/Public/MyUserWidget.h b/Source/MyProject/Public/MyUserWidget.h index 245f8ba..ff50db9 100644 --- a/Source/MyProject/Public/MyUserWidget.h +++ b/Source/MyProject/Public/MyUserWidget.h @@ -5,6 +5,7 @@ #include "Blueprint/UserWidget.h" #include "CoreMinimal.h" #include +#include #include "MyUserWidget.generated.h" /** @@ -76,4 +77,8 @@ class MYPROJECT_API UMyUserWidget : public UUserWidget { bool AllVerified(); void NativeOnInitialized() override; + +public: + UPROPERTY(meta = (BindWidget), BlueprintReadWrite) + UModeInputTextBox * commandInput; };