You've already forked UnrealEngineUWP
mirror of
https://github.com/izzy2lost/UnrealEngineUWP.git
synced 2026-03-26 18:15:20 -07:00
#ROBOMERGE-SOURCE: CL 5484017 via CL 5484024 via CL 5484034 via CL 5484044 via CL 5487293 [CL 5487477 by nick darnell in Main branch]
198 lines
5.5 KiB
C++
198 lines
5.5 KiB
C++
// Copyright 1998-2019 Epic Games, Inc. All Rights Reserved.
|
|
|
|
#include "Components/MultiLineEditableTextBox.h"
|
|
#include "UObject/ConstructorHelpers.h"
|
|
#include "Engine/Font.h"
|
|
#include "Widgets/DeclarativeSyntaxSupport.h"
|
|
#include "Widgets/Input/SMultiLineEditableTextBox.h"
|
|
|
|
#define LOCTEXT_NAMESPACE "UMG"
|
|
|
|
/////////////////////////////////////////////////////
|
|
// UMultiLineEditableTextBox
|
|
|
|
UMultiLineEditableTextBox::UMultiLineEditableTextBox(const FObjectInitializer& ObjectInitializer)
|
|
: Super(ObjectInitializer)
|
|
{
|
|
ForegroundColor_DEPRECATED = FLinearColor::Black;
|
|
BackgroundColor_DEPRECATED = FLinearColor::White;
|
|
ReadOnlyForegroundColor_DEPRECATED = FLinearColor::Black;
|
|
|
|
// HACK: THIS SHOULD NOT COME FROM CORESTYLE AND SHOULD INSTEAD BY DEFINED BY ENGINE TEXTURES/PROJECT SETTINGS
|
|
WidgetStyle = FCoreStyle::Get().GetWidgetStyle<FEditableTextBoxStyle>("NormalEditableTextBox");
|
|
TextStyle = FCoreStyle::Get().GetWidgetStyle<FTextBlockStyle>("NormalText");
|
|
|
|
bIsReadOnly = false;
|
|
AllowContextMenu = true;
|
|
VirtualKeyboardDismissAction = EVirtualKeyboardDismissAction::TextChangeOnDismiss;
|
|
AutoWrapText = true;
|
|
|
|
if (!IsRunningDedicatedServer())
|
|
{
|
|
static ConstructorHelpers::FObjectFinder<UFont> RobotoFontObj(*UWidget::GetDefaultFontName());
|
|
Font_DEPRECATED = FSlateFontInfo(RobotoFontObj.Object, 12, FName("Bold"));
|
|
|
|
WidgetStyle.SetFont(Font_DEPRECATED);
|
|
WidgetStyle.SetForegroundColor(ForegroundColor_DEPRECATED);
|
|
WidgetStyle.SetBackgroundColor(BackgroundColor_DEPRECATED);
|
|
WidgetStyle.SetReadOnlyForegroundColor(ReadOnlyForegroundColor_DEPRECATED);
|
|
}
|
|
}
|
|
|
|
void UMultiLineEditableTextBox::ReleaseSlateResources(bool bReleaseChildren)
|
|
{
|
|
Super::ReleaseSlateResources(bReleaseChildren);
|
|
|
|
MyEditableTextBlock.Reset();
|
|
}
|
|
|
|
TSharedRef<SWidget> UMultiLineEditableTextBox::RebuildWidget()
|
|
{
|
|
MyEditableTextBlock = SNew(SMultiLineEditableTextBox)
|
|
.Style(&WidgetStyle)
|
|
.TextStyle(&TextStyle)
|
|
.AllowContextMenu(AllowContextMenu)
|
|
.IsReadOnly(bIsReadOnly)
|
|
// .MinDesiredWidth(MinimumDesiredWidth)
|
|
// .Padding(Padding)
|
|
// .IsCaretMovedWhenGainFocus(IsCaretMovedWhenGainFocus)
|
|
// .SelectAllTextWhenFocused(SelectAllTextWhenFocused)
|
|
// .RevertTextOnEscape(RevertTextOnEscape)
|
|
// .ClearKeyboardFocusOnCommit(ClearKeyboardFocusOnCommit)
|
|
// .SelectAllTextOnCommit(SelectAllTextOnCommit)
|
|
.VirtualKeyboardOptions(VirtualKeyboardOptions)
|
|
.VirtualKeyboardDismissAction(VirtualKeyboardDismissAction)
|
|
.OnTextChanged(BIND_UOBJECT_DELEGATE(FOnTextChanged, HandleOnTextChanged))
|
|
.OnTextCommitted(BIND_UOBJECT_DELEGATE(FOnTextCommitted, HandleOnTextCommitted))
|
|
;
|
|
|
|
return MyEditableTextBlock.ToSharedRef();
|
|
}
|
|
|
|
void UMultiLineEditableTextBox::SynchronizeProperties()
|
|
{
|
|
Super::SynchronizeProperties();
|
|
|
|
TAttribute<FText> HintTextBinding = PROPERTY_BINDING(FText, HintText);
|
|
|
|
MyEditableTextBlock->SetStyle(&WidgetStyle);
|
|
MyEditableTextBlock->SetText(Text);
|
|
MyEditableTextBlock->SetHintText(HintTextBinding);
|
|
MyEditableTextBlock->SetAllowContextMenu(AllowContextMenu);
|
|
MyEditableTextBlock->SetIsReadOnly(bIsReadOnly);
|
|
MyEditableTextBlock->SetVirtualKeyboardDismissAction(VirtualKeyboardDismissAction);
|
|
|
|
// MyEditableTextBlock->SetIsPassword(IsPassword);
|
|
// MyEditableTextBlock->SetColorAndOpacity(ColorAndOpacity);
|
|
|
|
// TODO UMG Complete making all properties settable on SMultiLineEditableTextBox
|
|
|
|
Super::SynchronizeTextLayoutProperties(*MyEditableTextBlock);
|
|
}
|
|
|
|
FText UMultiLineEditableTextBox::GetText() const
|
|
{
|
|
if ( MyEditableTextBlock.IsValid() )
|
|
{
|
|
return MyEditableTextBlock->GetText();
|
|
}
|
|
|
|
return Text;
|
|
}
|
|
|
|
void UMultiLineEditableTextBox::SetText(FText InText)
|
|
{
|
|
Text = InText;
|
|
if ( MyEditableTextBlock.IsValid() )
|
|
{
|
|
MyEditableTextBlock->SetText(Text);
|
|
}
|
|
}
|
|
|
|
void UMultiLineEditableTextBox::SetError(FText InError)
|
|
{
|
|
if ( MyEditableTextBlock.IsValid() )
|
|
{
|
|
MyEditableTextBlock->SetError(InError);
|
|
}
|
|
}
|
|
|
|
void UMultiLineEditableTextBox::SetIsReadOnly(bool bReadOnly)
|
|
{
|
|
bIsReadOnly = bReadOnly;
|
|
|
|
if ( MyEditableTextBlock.IsValid() )
|
|
{
|
|
MyEditableTextBlock->SetIsReadOnly(bIsReadOnly);
|
|
}
|
|
}
|
|
|
|
void UMultiLineEditableTextBox::HandleOnTextChanged(const FText& InText)
|
|
{
|
|
OnTextChanged.Broadcast(InText);
|
|
}
|
|
|
|
void UMultiLineEditableTextBox::HandleOnTextCommitted(const FText& InText, ETextCommit::Type CommitMethod)
|
|
{
|
|
OnTextCommitted.Broadcast(InText, CommitMethod);
|
|
}
|
|
|
|
void UMultiLineEditableTextBox::PostLoad()
|
|
{
|
|
Super::PostLoad();
|
|
|
|
if ( GetLinkerUE4Version() < VER_UE4_DEPRECATE_UMG_STYLE_ASSETS )
|
|
{
|
|
if ( Style_DEPRECATED != nullptr )
|
|
{
|
|
const FEditableTextBoxStyle* StylePtr = Style_DEPRECATED->GetStyle<FEditableTextBoxStyle>();
|
|
if ( StylePtr != nullptr )
|
|
{
|
|
WidgetStyle = *StylePtr;
|
|
}
|
|
|
|
Style_DEPRECATED = nullptr;
|
|
}
|
|
}
|
|
|
|
if (GetLinkerUE4Version() < VER_UE4_DEPRECATE_UMG_STYLE_OVERRIDES)
|
|
{
|
|
if (Font_DEPRECATED.HasValidFont())
|
|
{
|
|
WidgetStyle.Font = Font_DEPRECATED;
|
|
Font_DEPRECATED = FSlateFontInfo();
|
|
}
|
|
|
|
if (ForegroundColor_DEPRECATED != FLinearColor::Black)
|
|
{
|
|
WidgetStyle.ForegroundColor = ForegroundColor_DEPRECATED;
|
|
ForegroundColor_DEPRECATED = FLinearColor::Black;
|
|
}
|
|
|
|
if (BackgroundColor_DEPRECATED != FLinearColor::White)
|
|
{
|
|
WidgetStyle.BackgroundColor = BackgroundColor_DEPRECATED;
|
|
BackgroundColor_DEPRECATED = FLinearColor::White;
|
|
}
|
|
|
|
if (ReadOnlyForegroundColor_DEPRECATED != FLinearColor::Black)
|
|
{
|
|
WidgetStyle.ReadOnlyForegroundColor = ReadOnlyForegroundColor_DEPRECATED;
|
|
ReadOnlyForegroundColor_DEPRECATED = FLinearColor::Black;
|
|
}
|
|
}
|
|
}
|
|
|
|
#if WITH_EDITOR
|
|
|
|
const FText UMultiLineEditableTextBox::GetPaletteCategory()
|
|
{
|
|
return LOCTEXT("Input", "Input");
|
|
}
|
|
|
|
#endif
|
|
|
|
/////////////////////////////////////////////////////
|
|
|
|
#undef LOCTEXT_NAMESPACE
|