UDocumentation UE5.7 10.02.2026 (Source)
API documentation for Unreal Engine 5.7
TextBlock.h
Go to the documentation of this file.
1// Copyright Epic Games, Inc. All Rights Reserved.
2
3#pragma once
4
5#include "CoreMinimal.h"
9#include "Widgets/SWidget.h"
11#include "TextBlock.generated.h"
12
13class STextBlock;
15
22UCLASS(meta=(DisplayName="Text"), MinimalAPI)
24{
26
27public:
28 UE_DEPRECATED(5.1, "Direct access to Text is deprecated. Please use the getter or setter.")
30 UPROPERTY(EditAnywhere, BlueprintReadWrite, Getter, Setter, BlueprintGetter="GetText", BlueprintSetter="SetText", Category="Content", meta = (MultiLine = "true"))
32
34 UPROPERTY()
35 FGetText TextDelegate;
36
37 UE_DEPRECATED(5.1, "Direct access to ColorAndOpacity is deprecated. Please use the getter or setter.")
39 UPROPERTY(EditAnywhere, BlueprintReadWrite, Getter, Setter, BlueprintSetter="SetColorAndOpacity", Category="Appearance")
40 FSlateColor ColorAndOpacity;
41
43 UPROPERTY()
44 FGetSlateColor ColorAndOpacityDelegate;
45
46 UE_DEPRECATED(5.1, "Direct access to MinDesiredWidth is deprecated. Please use the getter or setter.")
48 UPROPERTY(EditAnywhere, BlueprintReadWrite, Getter, Setter, BlueprintSetter="SetMinDesiredWidth", Category="Appearance")
49 float MinDesiredWidth;
50
51 UE_DEPRECATED(5.1, "Direct access to Font is deprecated. Please use the getter or setter.")
53 UPROPERTY(EditAnywhere, BlueprintReadWrite, Getter, Setter, BlueprintSetter="SetFont", Category="Appearance")
55
56 UE_DEPRECATED(5.1, "Direct access to StrikeBrush is deprecated. Please use the getter or setter.")
58 UPROPERTY(EditAnywhere, BlueprintReadWrite, Getter, Setter, BlueprintSetter="SetStrikeBrush", Category="Appearance")
59 FSlateBrush StrikeBrush;
60
61 UE_DEPRECATED(5.1, "Direct access to ShadowOffset is deprecated. Please use the getter or setter.")
63 UPROPERTY(EditAnywhere, BlueprintReadWrite, Getter, Setter, BlueprintSetter="SetShadowOffset", Category="Appearance")
64 FVector2D ShadowOffset;
65
66 UE_DEPRECATED(5.1, "Direct access to ShadowColorAndOpacity is deprecated. Please use the getter or setter.")
68 UPROPERTY(EditAnywhere, BlueprintReadWrite, Getter, Setter, BlueprintSetter="SetShadowColorAndOpacity", Category="Appearance", meta=( DisplayName="Shadow Color" ))
69 FLinearColor ShadowColorAndOpacity;
70
72 UPROPERTY()
73 FGetLinearColor ShadowColorAndOpacityDelegate;
74
76 UPROPERTY(EditAnywhere, BlueprintReadOnly, Category="Performance", AdvancedDisplay)
77 bool bWrapWithInvalidationPanel;
78
79 UE_DEPRECATED(5.1, "Direct access to TextTransformPolicy is deprecated. Please use the getter or setter.")
81 UPROPERTY(EditAnywhere, BlueprintReadWrite, Getter, Setter, BlueprintSetter="SetTextTransformPolicy", Category="Appearance", meta=(DisplayName="Transform Policy"))
82 ETextTransformPolicy TextTransformPolicy;
83
84 UE_DEPRECATED(5.1, "Direct access to TextOverflowPolicy is deprecated. Please use the getter or setter.")
86 UPROPERTY(EditAnywhere, BlueprintReadWrite, Getter, Setter, BlueprintSetter="SetTextOverflowPolicy", Category="Clipping", AdvancedDisplay, meta = (DisplayName="Overflow Policy"))
87 ETextOverflowPolicy TextOverflowPolicy;
88
89public:
94 UFUNCTION(BlueprintCallable, Category="Widget", meta=(DisplayName="GetText (Text)"))
95 UMG_API FText GetText() const;
96
102 UFUNCTION(BlueprintCallable, Category="Widget", meta=(DisplayName="SetText (Text)"))
103 UMG_API virtual void SetText(FText InText);
104
106 UMG_API FSlateColor GetColorAndOpacity() const;
107
113 UFUNCTION(BlueprintCallable, Category="Appearance")
114 UMG_API void SetColorAndOpacity(FSlateColor InColorAndOpacity);
115
121 UFUNCTION(BlueprintCallable, Category="Appearance")
122 UMG_API void SetOpacity(float InOpacity);
123
125 UMG_API FLinearColor GetShadowColorAndOpacity() const;
126
133 UFUNCTION(BlueprintCallable, Category="Appearance")
134 UMG_API void SetShadowColorAndOpacity(FLinearColor InShadowColorAndOpacity);
135
137 UMG_API FVector2D GetShadowOffset() const;
138
144 UFUNCTION(BlueprintCallable, Category="Appearance")
145 UMG_API void SetShadowOffset(FVector2D InShadowOffset);
146
148 UMG_API const FSlateFontInfo& GetFont() const;
149
155 UFUNCTION(BlueprintCallable, Category="Appearance")
156 UMG_API void SetFont(FSlateFontInfo InFontInfo);
157
159 UMG_API const FSlateBrush& GetStrikeBrush() const;
160
166 UFUNCTION(BlueprintCallable, Category="Appearance")
167 UMG_API void SetStrikeBrush(FSlateBrush InStrikeBrush);
168
170 UMG_API float GetMinDesiredWidth() const;
171
177 UFUNCTION(BlueprintCallable, Category="Appearance")
178 UMG_API void SetMinDesiredWidth(float InMinDesiredWidth);
179
185 UFUNCTION(BlueprintCallable, Category="Appearance")
186 UMG_API void SetAutoWrapText(bool InAutoTextWrap);
187
189 UMG_API ETextTransformPolicy GetTextTransformPolicy() const;
190
196 UFUNCTION(BlueprintCallable, Category="Appearance")
197 UMG_API void SetTextTransformPolicy(ETextTransformPolicy InTransformPolicy);
198
200 UMG_API ETextOverflowPolicy GetTextOverflowPolicy() const;
201
207 UFUNCTION(BlueprintCallable, Category="Appearance")
208 UMG_API void SetTextOverflowPolicy(ETextOverflowPolicy InOverflowPolicy);
209
210 UFUNCTION(BlueprintCallable, Category="Appearance")
211 UMG_API void SetFontMaterial(UMaterialInterface* InMaterial);
212
213 UFUNCTION(BlueprintCallable, Category="Appearance")
214 UMG_API void SetFontOutlineMaterial(UMaterialInterface* InMaterial);
215
217 UFUNCTION(BlueprintCallable, Category="Appearance")
218 UMG_API UMaterialInstanceDynamic* GetDynamicFontMaterial();
219
221 UFUNCTION(BlueprintCallable, Category="Appearance")
222 UMG_API UMaterialInstanceDynamic* GetDynamicOutlineMaterial();
223
225 virtual void OnTextChanged()
226 {
227 }
228
229 virtual void OnFontChanged()
230 {
231 }
232
233public:
234 //~ Begin UWidget Interface
235 UMG_API virtual void SynchronizeProperties() override;
236 //~ End UWidget Interface
237
238 //~ Begin UVisual Interface
239 UMG_API virtual void ReleaseSlateResources(bool bReleaseChildren) override;
240 //~ End UVisual Interface
241
242#if WITH_EDITOR
243 //~ Begin UWidget Interface
244 UMG_API virtual const FText GetPaletteCategory() override;
245 UMG_API virtual void OnCreationFromPalette() override;
246 UMG_API virtual bool CanEditChange(const FProperty* InProperty) const override;
247 //~ End UWidget Interface
248
249 UMG_API virtual FString GetLabelMetadata() const override;
250
251 UMG_API void HandleTextCommitted(const FText& InText, ETextCommit::Type CommitteType);
252#endif
253
254protected:
255 //~ Begin UTextLayoutWidget Interface
256 UMG_API virtual void OnShapedTextOptionsChanged(FShapedTextOptions InShapedTextOptions) override;
257 UMG_API virtual void OnJustificationChanged(ETextJustify::Type InJustification) override;
258 UMG_API virtual void OnWrappingPolicyChanged(ETextWrappingPolicy InWrappingPolicy) override;
259 UMG_API virtual void OnAutoWrapTextChanged(bool InAutoWrapText) override;
260 UMG_API virtual void OnWrapTextAtChanged(float InWrapTextAt) override;
261 UMG_API virtual void OnLineHeightPercentageChanged(float InLineHeightPercentage) override;
262 UMG_API virtual void OnApplyLineHeightToBottomLineChanged(bool InApplyLineHeightToBottomLine) override;
263 UMG_API virtual void OnMarginChanged(const FMargin& InMargin) override;
264 //~ End UTextLayoutWidget Interface
265
271 UPROPERTY(EditAnywhere, BlueprintReadOnly, Category=Performance, AdvancedDisplay, meta=(AllowPrivateAccess = "true", DesignerRebuild))
272 bool bSimpleTextMode;
273
274 //~ Begin UWidget Interface
275 UMG_API virtual TSharedRef<SWidget> RebuildWidget() override;
276 UMG_API virtual void OnBindingChanged(const FName& Property) override;
277 //~ End UWidget Interface
278
280 UMG_API virtual TAttribute<FText> GetDisplayText();
281
282 UMG_API EVisibility GetTextWarningImageVisibility() const;
283
284#if WITH_ACCESSIBILITY
285 UMG_API virtual TSharedPtr<SWidget> GetAccessibleWidget() const override;
286#endif
287
288protected:
289
291
295};
#define UE_DEPRECATED(Version, Message)
Definition CoreMiscDefines.h:302
UE_FORCEINLINE_HINT TSharedRef< CastToType, Mode > StaticCastSharedRef(TSharedRef< CastFromType, Mode > const &InSharedRef)
Definition SharedPointer.h:127
const bool
Definition NetworkReplayStreaming.h:178
#define UPROPERTY(...)
UObject definition macros.
Definition ObjectMacros.h:744
#define UFUNCTION(...)
Definition ObjectMacros.h:745
#define GENERATED_UCLASS_BODY(...)
Definition ObjectMacros.h:768
#define UCLASS(...)
Definition ObjectMacros.h:776
ETextTransformPolicy
Definition SlateTypes.h:310
ETextOverflowPolicy
Definition SlateTypes.h:79
ETextWrappingPolicy
Definition TextLayout.h:67
Definition NameTypes.h:617
Definition UnrealType.h:174
Definition Text.h:385
Definition STextBlock.h:45
Definition SWidget.h:165
Definition Attribute.h:17
Definition SharedPointer.h:692
Definition SharedPointer.h:153
Definition MaterialInstanceDynamic.h:15
Definition MaterialInterface.h:296
Definition TextBlock.h:24
TSharedPtr< STextBlock > MyTextBlock
Definition TextBlock.h:290
virtual void OnFontChanged()
Definition TextBlock.h:229
PROPERTY_BINDING_IMPLEMENTATION(FSlateColor, ColorAndOpacity)
PROPERTY_BINDING_IMPLEMENTATION(FText, Text)
PROPERTY_BINDING_IMPLEMENTATION(FLinearColor, ShadowColorAndOpacity)
Definition TextWidgetTypes.h:71
Type
Definition SlateEnums.h:291
Type
Definition TextLayout.h:28
Definition Visibility.h:12
Definition Color.h:48
Definition Margin.h:17
Definition TextWidgetTypes.h:21
Definition SlateBrush.h:239
Definition SlateColor.h:42
Definition SlateFontInfo.h:147