You've already forked UnrealEngineUWP
mirror of
https://github.com/izzy2lost/UnrealEngineUWP.git
synced 2026-03-26 18:15:20 -07:00
#rnx #rb none #ROBOMERGE-SOURCE: CL 10869241 via CL 10869527 via CL 10869904 #ROBOMERGE-BOT: (v613-10869866) [CL 10870586 by ryan durand in Main branch]
65 lines
1.5 KiB
C++
65 lines
1.5 KiB
C++
// Copyright Epic Games, Inc. All Rights Reserved.
|
|
|
|
#include "SourcesSearch.h"
|
|
#include "Widgets/Input/SSearchBox.h"
|
|
#include "Framework/Application/SlateApplication.h"
|
|
|
|
void FSourcesSearch::Initialize()
|
|
{
|
|
SearchBox = SNew(SSearchBox)
|
|
.OnTextChanged(this, &FSourcesSearch::OnSearchBoxTextChanged)
|
|
.OnTextCommitted(this, &FSourcesSearch::OnSearchBoxTextCommitted);
|
|
}
|
|
|
|
void FSourcesSearch::ClearSearch()
|
|
{
|
|
if (!SearchBox->GetSearchText().IsEmpty())
|
|
{
|
|
SearchBox->SetSearchText(FText::GetEmpty());
|
|
}
|
|
}
|
|
|
|
void FSourcesSearch::SetHintText(const TAttribute<FText>& InHintText)
|
|
{
|
|
SearchBox->SetHintText(InHintText);
|
|
}
|
|
|
|
TSharedRef<SWidget> FSourcesSearch::GetWidget() const
|
|
{
|
|
return SearchBox.ToSharedRef();
|
|
}
|
|
|
|
void FSourcesSearch::OnSearchBoxTextChanged(const FText& InSearchText)
|
|
{
|
|
TArray<FText> SearchErrors;
|
|
OnSearchChangedDelegate.Broadcast(InSearchText, SearchErrors);
|
|
|
|
if (SearchErrors.Num() == 0)
|
|
{
|
|
SearchBox->SetError(FText::GetEmpty());
|
|
}
|
|
else if (SearchErrors.Num() == 1)
|
|
{
|
|
SearchBox->SetError(SearchErrors[0]);
|
|
}
|
|
else
|
|
{
|
|
FTextBuilder CombinedError;
|
|
for (const FText& SearchError : SearchErrors)
|
|
{
|
|
CombinedError.AppendLine(SearchError);
|
|
}
|
|
SearchBox->SetError(CombinedError.ToText());
|
|
}
|
|
}
|
|
|
|
void FSourcesSearch::OnSearchBoxTextCommitted(const FText& InSearchText, ETextCommit::Type InCommitType)
|
|
{
|
|
if (InCommitType == ETextCommit::OnCleared)
|
|
{
|
|
// Clear the search box
|
|
ClearSearch();
|
|
FSlateApplication::Get().ClearKeyboardFocus(EFocusCause::Cleared);
|
|
}
|
|
}
|