You've already forked UnrealEngineUWP
mirror of
https://github.com/izzy2lost/UnrealEngineUWP.git
synced 2026-03-26 18:15:20 -07:00
119 lines
3.6 KiB
C++
119 lines
3.6 KiB
C++
// Copyright 1998-2014 Epic Games, Inc. All Rights Reserved.
|
|
|
|
#include "UMGPrivatePCH.h"
|
|
|
|
#define LOCTEXT_NAMESPACE "UMG"
|
|
|
|
/////////////////////////////////////////////////////
|
|
// UMultiLineEditableText
|
|
|
|
UMultiLineEditableText::UMultiLineEditableText(const FObjectInitializer& ObjectInitializer)
|
|
: Super(ObjectInitializer)
|
|
{
|
|
SMultiLineEditableText::FArguments Defaults;
|
|
WidgetStyle = *Defaults._TextStyle;
|
|
|
|
bAutoWrapText = true;
|
|
// HACK Special font initialization hack since there are no font assets yet for slate.
|
|
Font = FSlateFontInfo(TEXT("Slate/Fonts/Roboto-Bold.ttf"), 12);
|
|
}
|
|
|
|
void UMultiLineEditableText::ReleaseSlateResources(bool bReleaseChildren)
|
|
{
|
|
Super::ReleaseSlateResources(bReleaseChildren);
|
|
|
|
MyMultiLineEditableText.Reset();
|
|
}
|
|
|
|
TSharedRef<SWidget> UMultiLineEditableText::RebuildWidget()
|
|
{
|
|
FString FontPath = FPaths::GameContentDir() / Font.FontName.ToString();
|
|
|
|
if ( !FPaths::FileExists(FontPath) )
|
|
{
|
|
FontPath = FPaths::EngineContentDir() / Font.FontName.ToString();
|
|
}
|
|
|
|
MyMultiLineEditableText = SNew(SMultiLineEditableText)
|
|
.TextStyle(&WidgetStyle)
|
|
.Font(FSlateFontInfo(FontPath, Font.Size))
|
|
.Justification(Justification)
|
|
.WrapTextAt( WrapTextAt )
|
|
.AutoWrapText( bAutoWrapText )
|
|
// .MinDesiredWidth(MinimumDesiredWidth)
|
|
// .IsCaretMovedWhenGainFocus(IsCaretMovedWhenGainFocus)
|
|
// .SelectAllTextWhenFocused(SelectAllTextWhenFocused)
|
|
// .RevertTextOnEscape(RevertTextOnEscape)
|
|
// .ClearKeyboardFocusOnCommit(ClearKeyboardFocusOnCommit)
|
|
// .SelectAllTextOnCommit(SelectAllTextOnCommit)
|
|
// .BackgroundImageSelected(BackgroundImageSelected ? TAttribute<const FSlateBrush*>(&BackgroundImageSelected->Brush) : TAttribute<const FSlateBrush*>())
|
|
// .BackgroundImageSelectionTarget(BackgroundImageSelectionTarget ? TAttribute<const FSlateBrush*>(&BackgroundImageSelectionTarget->Brush) : TAttribute<const FSlateBrush*>())
|
|
// .BackgroundImageComposing(BackgroundImageComposing ? TAttribute<const FSlateBrush*>(&BackgroundImageComposing->Brush) : TAttribute<const FSlateBrush*>())
|
|
// .CaretImage(CaretImage ? TAttribute<const FSlateBrush*>(&CaretImage->Brush) : TAttribute<const FSlateBrush*>())
|
|
// .OnTextChanged(BIND_UOBJECT_DELEGATE(FOnTextChanged, HandleOnTextChanged))
|
|
// .OnTextCommitted(BIND_UOBJECT_DELEGATE(FOnTextCommitted, HandleOnTextCommitted))
|
|
;
|
|
|
|
return BuildDesignTimeWidget( MyMultiLineEditableText.ToSharedRef() );
|
|
}
|
|
|
|
void UMultiLineEditableText::SynchronizeProperties()
|
|
{
|
|
Super::SynchronizeProperties();
|
|
|
|
MyMultiLineEditableText->SetText(Text);
|
|
// MyMultiLineEditableText->SetHintText(HintText);
|
|
// MyMultiLineEditableText->SetIsReadOnly(IsReadOnly);
|
|
// MyMultiLineEditableText->SetIsPassword(IsPassword);
|
|
// MyMultiLineEditableText->SetColorAndOpacity(ColorAndOpacity);
|
|
|
|
// TODO UMG Complete making all properties settable on SMultiLineEditableText
|
|
}
|
|
|
|
FText UMultiLineEditableText::GetText() const
|
|
{
|
|
if ( MyMultiLineEditableText.IsValid() )
|
|
{
|
|
return MyMultiLineEditableText->GetText();
|
|
}
|
|
|
|
return Text;
|
|
}
|
|
|
|
void UMultiLineEditableText::SetText(FText InText)
|
|
{
|
|
Text = InText;
|
|
if ( MyMultiLineEditableText.IsValid() )
|
|
{
|
|
MyMultiLineEditableText->SetText(Text);
|
|
}
|
|
}
|
|
|
|
void UMultiLineEditableText::HandleOnTextChanged(const FText& Text)
|
|
{
|
|
OnTextChanged.Broadcast(Text);
|
|
}
|
|
|
|
void UMultiLineEditableText::HandleOnTextCommitted(const FText& Text, ETextCommit::Type CommitMethod)
|
|
{
|
|
OnTextCommitted.Broadcast(Text, CommitMethod);
|
|
}
|
|
|
|
#if WITH_EDITOR
|
|
|
|
const FSlateBrush* UMultiLineEditableText::GetEditorIcon()
|
|
{
|
|
return FUMGStyle::Get().GetBrush("Widget.MultiLineEditableText");
|
|
}
|
|
|
|
const FText UMultiLineEditableText::GetPaletteCategory()
|
|
{
|
|
return LOCTEXT("Primitive", "Primitive");
|
|
}
|
|
|
|
#endif
|
|
|
|
/////////////////////////////////////////////////////
|
|
|
|
#undef LOCTEXT_NAMESPACE
|