A Demo Project for the UnrealEngineSDK
Loading...
Searching...
No Matches
DialogueMultiLineEditableTextBox_CustomRowHelper.cpp
Go to the documentation of this file.
1// Copyright Csaba Molnar, Daniel Butum. All Rights Reserved.
3
4#include "PropertyHandle.h"
5#include "DetailWidgetRow.h"
6#include "Widgets/Input/SButton.h"
7#include "Widgets/Images/SImage.h"
8#include "Widgets/Input/SComboButton.h"
9#include "Widgets/Layout/SUniformGridPanel.h"
10#include "Internationalization/TextNamespaceUtil.h"
11#include "IPropertyUtilities.h"
14
15#define LOCTEXT_NAMESPACE "MultiLineEditableTextBox_CustomRowHelper"
16
18// FDialogueMultiLineEditableTextBoxOptions
20{
21 const auto DefaultValues = Self{};
22
23 // Set default values
24 bSelectAllTextWhenFocused = DefaultValues.bSelectAllTextWhenFocused;
25 bClearKeyboardFocusOnCommit = DefaultValues.bClearKeyboardFocusOnCommit;
26 bSelectAllTextOnCommit = DefaultValues.bSelectAllTextOnCommit;
27 bAutoWrapText = DefaultValues.bAutoWrapText;
28 WrapTextAt = DefaultValues.WrapTextAt;
30
31 // Set values that can't be set in the class definition
32 Style = FCoreStyle::Get().GetWidgetStyle<FEditableTextBoxStyle>("NormalEditableTextBox");
33 Font = FEditorStyle::GetFontStyle(TEXT("PropertyWindow.NormalFont"));
34 // ForegroundColor =
35}
36
38// FDialogueMultiLineEditableTextBox_CustomRowHelper
40{
41 check(PropertyHandle.IsValid());
42 check(PropertyUtils.IsValid());
43
44 EditableTextProperty = MakeShared<FDialogueEditableTextPropertyHandle>(PropertyHandle.ToSharedRef(), PropertyUtils);
45
46 TSharedPtr<SHorizontalBox> HorizontalBox;
48 ->NameContent()
49 [
50 NameContentWidget.ToSharedRef()
51 ]
52 .ValueContent()
53 // Similar to TextProperty, see FTextCustomization
54 .MinDesiredWidth(209.f)
55 .MaxDesiredWidth(600.f)
56 [
57 SAssignNew(HorizontalBox, SHorizontalBox)
58 +SHorizontalBox::Slot()
59 .Padding(0.f, 0.f, 4.f, 0.f)
60 .FillWidth(1.f)
61 [
62 // Set custom size of text box
63 // SNew(SBox)
64 // .HeightOverride(100)
65 // [
66 //MultiLineEditableTextBoxWidget.ToSharedRef()
67 // ]
68 //
70 .Style(&Options.Style)
71 .Font(Options.Font)
72 .ForegroundColor(Options.ForegroundColor)
73 .ReadOnlyForegroundColor(Options.ReadOnlyForegroundColor)
74 .SelectAllTextWhenFocused(Options.bSelectAllTextWhenFocused)
75 .ClearKeyboardFocusOnCommit(Options.bClearKeyboardFocusOnCommit)
76 .SelectAllTextOnCommit(Options.bSelectAllTextOnCommit)
77 .AutoWrapText(Options.bAutoWrapText)
78 .WrapTextAt(Options.WrapTextAt)
79 .ModiferKeyForNewLine(Options.ModiferKeyForNewLine)
80 .AddResetToDefaultWidget(true)
81 ]
82 ];
83}
84
86{
87 check(TextBoxWidget.IsValid());
88 return TextBoxWidget->OnTextCommittedEvent();
89}
90
92{
93 check(TextBoxWidget.IsValid());
94 return TextBoxWidget->OnTextChangedEvent();
95}
96
98{
99 if (TextBoxWidget.IsValid())
100 {
101 return TextBoxWidget->GetTextValue();
102 }
103
104 return FText::GetEmpty();
105}
106
107#undef LOCTEXT_NAMESPACE
TSharedPtr< IPropertyUtilities > PropertyUtils
TSharedPtr< IPropertyHandle > PropertyHandle
static EModifierKey::Type GetModifierKeyFromDialogueSettings()