4#include "PropertyHandle.h"
5#include "Widgets/Input/SSearchBox.h"
6#include "Framework/Application/SlateApplication.h"
7#include "DetailWidgetRow.h"
8#include "IDocumentation.h"
9#include "Layout/WidgetPath.h"
11#define LOCTEXT_NAMESPACE "SDialogueTextPropertyPickList"
18 if (InArgs._PropertyHandle.IsValid())
39 TSharedPtr<SHorizontalBox> ContentBox = SNew(SHorizontalBox);
42 ContentBox.ToSharedRef()
57 .ButtonStyle(FEditorStyle::Get(),
"PropertyEditor.AssetComboStyle")
58 .ForegroundColor(FEditorStyle::GetColor(
"PropertyEditor.AssetName.ColorAndOpacity"))
69 .TextStyle(FEditorStyle::Get(),
"PropertyEditor.AssetClass")
76 +SHorizontalBox::Slot()
93 if (InKeyEvent.GetKey() == EKeys::Escape)
97 return FReply::Handled();
100 return FReply::Unhandled();
105 const FText NewText = InNewText.Get();
121 const FText NewText = InNewText.Get();
133 if (
PropertyHandle->GetValueAsFormattedText(ReadData) == FPropertyAccess::Success)
144 return SNew(SVerticalBox)
145 +SVerticalBox::Slot()
147 .Padding(2.f, 2.f, 2.f, 5.f)
161 .Padding(0.f, 0.f, 0.f, 1.f)
170 .Padding(0.f, 0.f, 0.f, 1.f)
173 .Text(LOCTEXT(
"SearchHeader",
"Search or Set new text (press enter)"))
174 .TextStyle(FCoreStyle::Get(), TEXT(
"Menu.Heading"))
201 return SNew(SHorizontalBox)
204 +SHorizontalBox::Slot()
205 .HAlign(HAlign_Right)
206 .VAlign(VAlign_Center)
232 return SNew(SHorizontalBox)
233 +SHorizontalBox::Slot()
246 .SelectAllTextWhenFocused(
true)
259 return SNew(SOverlay)
269 .BorderImage(FEditorStyle::GetBrush(
"NoBorder"));
272 .SelectionMode(ESelectionMode::Single)
286 check(Text.IsValid());
290 .Text(FText::FromName(*Text.Get()))
299 FSlateApplication::Get().ClearKeyboardFocus(EFocusCause::SetDirectly);
324 if (CommitType == ETextCommit::Default)
331 if (SelectedSuggestion.IsValid() && CommitType != ETextCommit::OnCleared)
334 CommittedText = FText::FromName(*SelectedSuggestion.Get());
338 if (CommitType == ETextCommit::OnCleared)
341 CommittedText = FText::GetEmpty();
346 CommittedText = NewText;
351 if (CommittedText.IdenticalTo(FText::GetEmpty()))
353 CommittedText = FText::FromName(NAME_None);
361 if (CommitType != ETextCommit::OnUserMovedFocus)
369 if (InKeyEvent.GetKey() == EKeys::Up || InKeyEvent.GetKey() == EKeys::Down)
371 const bool bSelectingUp = InKeyEvent.GetKey() == EKeys::Up;
374 if (SelectedSuggestion.IsValid())
377 int32 TargetIdx = INDEX_NONE;
378 for (int32 SuggestionIdx = 0; SuggestionIdx <
Suggestions.Num(); ++SuggestionIdx)
380 if (
Suggestions[SuggestionIdx] == SelectedSuggestion)
384 TargetIdx = SuggestionIdx - 1;
388 TargetIdx = SuggestionIdx + 1;
407 return FReply::Handled();
415 return FReply::Unhandled();
421 if (SelectInfo == ESelectInfo::OnMouseClick || SelectInfo == ESelectInfo::OnKeyPress || SelectInfo == ESelectInfo::Direct )
423 if (NewValue.IsValid())
425 SetText(FText::FromName(*NewValue.Get()));
452 TArray<FName> AllSuggestions;
465 if (TypedText.Len() > 0 && TypedText !=
TextAttribute.Get().ToString())
468 for (
const FName& Suggestion : AllSuggestions)
470 if (Suggestion.ToString().Contains(TypedText))
479 for (
const FName& Suggestion : AllSuggestions)
493 FWidgetPath WidgetToFocusPath;
494 FSlateApplication::Get().GeneratePathToWidgetChecked(
InputTextWidget.ToSharedRef(), WidgetToFocusPath);
495 FSlateApplication::Get().SetKeyboardFocus(WidgetToFocusPath, EFocusCause::SetDirectly);
500 TSharedPtr<FName> SelectedSuggestion;
501 const TArray<TSharedPtr<FName>>& SelectedSuggestionList =
ListViewWidget->GetSelectedItems();
502 if (SelectedSuggestionList.Num() > 0)
505 check(SelectedSuggestionList.Num() == 1)
506 SelectedSuggestion = SelectedSuggestionList[0];
509 return SelectedSuggestion;
514#undef LOCTEXT_NAMESPACE
TSharedRef< SWidget > GetContextCheckBoxWidget()
void HandleTextChanged(const FText &InSearchText)
FText GetHighlightText() const
TAttribute< TArray< FName > > CurrentContextSuggestionAttributes
TSharedPtr< SComboButton > ComboButtonWidget
TArray< TextListItem > Suggestions
TSharedRef< SWidget > GetListViewWidget()
TAttribute< FText > TextAttribute
void SetText(const TAttribute< FText > &InNewText)
TSharedPtr< FName > TextListItem
void HandleListSelectionChanged(TextListItem NewValue, ESelectInfo::Type SelectInfo)
TSharedPtr< SVerticalBox > MenuWidget
FOnTextChanged OnTextChanged
TextListItem GetSelectedSuggestion() const
TSharedPtr< STextBlock > ComboButtonTextWidget
TAttribute< FText > HintTextAttribute
TSharedPtr< SListView< TextListItem > > ListViewWidget
TSharedPtr< IPropertyHandle > PropertyHandle
void FocusSearchBox() const
TAttribute< FText > ContextCheckBoxToolTipTextAttribute
void HandleMenuOpenChanged(bool bOpen)
TSharedRef< ITableRow > HandleListGenerateRow(TextListItem Text, const TSharedRef< STableViewBase > &OwnerTable)
bool bIsContextCheckBoxChecked
FOnKeyDown OnKeyDownHandler
FReply OnPreviewKeyDown(const FGeometry &MyGeometry, const FKeyEvent &InKeyEvent) override
void HandleTextCommitted(const FText &InSearchText, ETextCommit::Type CommitInfo)
void SetPropertyHandle(const TSharedPtr< IPropertyHandle > &InPropertyHandle)
TSharedRef< SWidget > GetMenuWidget()
void Construct(const FArguments &InArgs)
TAttribute< FText > ContextCheckBoxTextAttribute
FOnTextCommitted OnTextCommitted
TAttribute< FText > ToolTipAttribute
bool bDelayChangeNotificationsWhileTyping
TSharedPtr< SBorder > ListViewContainerWidget
void UpdateSuggestionList()
TSharedPtr< SSearchBox > InputTextWidget
ECheckBoxState IsContextCheckBoxChecked() const
TAttribute< TArray< FName > > SuggestionAttributes
void HandleComboBoxOpened()
TSharedRef< SWidget > CreateShadowOverlay(TSharedRef< STableViewBase > Table) const
void HandleContextCheckboxChanged(ECheckBoxState CheckState)
TSharedRef< SWidget > GetSearchBoxWidget()
FReply HandleKeyDown(const FGeometry &MyGeometry, const FKeyEvent &InKeyEvent)
TSharedPtr< SCheckBox > ContextCheckBoxWidget
void SetToolTipAttribute(const TAttribute< FText > &InNewText)