2014-07-18 14:19:14 -04:00
|
|
|
// Copyright 1998-2014 Epic Games, Inc. All Rights Reserved.
|
|
|
|
|
|
|
|
|
|
#include "UMGPrivatePCH.h"
|
|
|
|
|
|
|
|
|
|
#define LOCTEXT_NAMESPACE "UMG"
|
|
|
|
|
|
|
|
|
|
/////////////////////////////////////////////////////
|
|
|
|
|
// UMultiLineEditableTextBox
|
|
|
|
|
|
|
|
|
|
UMultiLineEditableTextBox::UMultiLineEditableTextBox(const FPostConstructInitializeProperties& PCIP)
|
|
|
|
|
: Super(PCIP)
|
|
|
|
|
{
|
|
|
|
|
ForegroundColor = FLinearColor::Black;
|
|
|
|
|
BackgroundColor = FLinearColor::White;
|
|
|
|
|
ReadOnlyForegroundColor = FLinearColor::Black;
|
|
|
|
|
|
|
|
|
|
// HACK Special font initialization hack since there are no font assets yet for slate.
|
|
|
|
|
Font = FSlateFontInfo(TEXT("Slate/Fonts/Roboto-Bold.ttf"), 12);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
TSharedRef<SWidget> UMultiLineEditableTextBox::RebuildWidget()
|
|
|
|
|
{
|
2014-07-29 13:27:59 -04:00
|
|
|
FString FontPath = FPaths::GameContentDir() / Font.FontName.ToString();
|
|
|
|
|
|
|
|
|
|
if ( !FPaths::FileExists(FontPath) )
|
|
|
|
|
{
|
|
|
|
|
FontPath = FPaths::EngineContentDir() / Font.FontName.ToString();
|
|
|
|
|
}
|
2014-07-18 14:19:14 -04:00
|
|
|
|
|
|
|
|
MyEditableTextBlock = SNew(SMultiLineEditableTextBox)
|
|
|
|
|
.Font(FSlateFontInfo(FontPath, Font.Size))
|
2014-07-23 11:45:49 -04:00
|
|
|
.Justification(Justification)
|
2014-07-18 14:19:14 -04:00
|
|
|
.ForegroundColor(ForegroundColor)
|
|
|
|
|
.BackgroundColor(BackgroundColor)
|
|
|
|
|
.ReadOnlyForegroundColor(ReadOnlyForegroundColor)
|
|
|
|
|
// .MinDesiredWidth(MinimumDesiredWidth)
|
|
|
|
|
// .Padding(Padding)
|
|
|
|
|
// .IsCaretMovedWhenGainFocus(IsCaretMovedWhenGainFocus)
|
|
|
|
|
// .SelectAllTextWhenFocused(SelectAllTextWhenFocused)
|
|
|
|
|
// .RevertTextOnEscape(RevertTextOnEscape)
|
|
|
|
|
// .ClearKeyboardFocusOnCommit(ClearKeyboardFocusOnCommit)
|
|
|
|
|
// .SelectAllTextOnCommit(SelectAllTextOnCommit)
|
|
|
|
|
// .OnTextChanged(BIND_UOBJECT_DELEGATE(FOnTextChanged, HandleOnTextChanged))
|
|
|
|
|
// .OnTextCommitted(BIND_UOBJECT_DELEGATE(FOnTextCommitted, HandleOnTextCommitted))
|
|
|
|
|
;
|
|
|
|
|
|
|
|
|
|
return MyEditableTextBlock.ToSharedRef();
|
|
|
|
|
}
|
|
|
|
|
|
2014-08-13 17:04:49 -04:00
|
|
|
void UMultiLineEditableTextBox::SynchronizeProperties()
|
2014-07-18 14:19:14 -04:00
|
|
|
{
|
2014-08-13 17:04:49 -04:00
|
|
|
Super::SynchronizeProperties();
|
2014-07-18 14:19:14 -04:00
|
|
|
|
|
|
|
|
//const FMultiLineEditableTextBoxStyle* StylePtr = ( Style != NULL ) ? Style->GetStyle<FMultiLineEditableTextBoxStyle>() : NULL;
|
|
|
|
|
//if ( StylePtr )
|
|
|
|
|
//{
|
|
|
|
|
// MyEditableTextBlock->SetStyle(StylePtr);
|
|
|
|
|
//}
|
|
|
|
|
|
|
|
|
|
MyEditableTextBlock->SetText(Text);
|
|
|
|
|
// MyEditableTextBlock->SetHintText(HintText);
|
|
|
|
|
// MyEditableTextBlock->SetIsReadOnly(IsReadOnly);
|
|
|
|
|
// MyEditableTextBlock->SetIsPassword(IsPassword);
|
|
|
|
|
// MyEditableTextBlock->SetColorAndOpacity(ColorAndOpacity);
|
|
|
|
|
|
|
|
|
|
// TODO UMG Complete making all properties settable on SMultiLineEditableTextBox
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
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::HandleOnTextChanged(const FText& Text)
|
|
|
|
|
{
|
|
|
|
|
OnTextChanged.Broadcast(Text);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void UMultiLineEditableTextBox::HandleOnTextCommitted(const FText& Text, ETextCommit::Type CommitMethod)
|
|
|
|
|
{
|
|
|
|
|
OnTextCommitted.Broadcast(Text, CommitMethod);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
#if WITH_EDITOR
|
|
|
|
|
|
|
|
|
|
const FSlateBrush* UMultiLineEditableTextBox::GetEditorIcon()
|
|
|
|
|
{
|
|
|
|
|
return FUMGStyle::Get().GetBrush("Widget.MultiLineEditableTextBox");
|
|
|
|
|
}
|
|
|
|
|
|
2014-09-15 11:21:09 -04:00
|
|
|
const FText UMultiLineEditableTextBox::GetPaletteCategory()
|
2014-09-03 12:32:27 -04:00
|
|
|
{
|
|
|
|
|
return LOCTEXT("Common", "Common");
|
|
|
|
|
}
|
|
|
|
|
|
2014-07-18 14:19:14 -04:00
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
/////////////////////////////////////////////////////
|
|
|
|
|
|
|
|
|
|
#undef LOCTEXT_NAMESPACE
|