Stream Chat Unreal SDK
Loading...
Searching...
No Matches
MessageComposerWidget.h
1// Copyright 2026 Stream.IO, Inc. All Rights Reserved.
2
3#pragma once
4
5#include "AttachmentPicker.h"
6#include "Blueprint/UserWidget.h"
7#include "Channel/ChatChannel.h"
8#include "Common/IconButton.h"
9#include "Components/Border.h"
10#include "Components/Button.h"
11#include "Components/Image.h"
12#include "Components/TextBlock.h"
13#include "CoreMinimal.h"
14#include "MessageInputWidget.h"
15#include "Types/SlateEnums.h"
16
17#include "MessageComposerWidget.generated.h"
18
22UCLASS()
23class STREAMCHATUI_API UMessageComposerWidget final : public UUserWidget
24{
25 GENERATED_BODY()
26
27public:
28 virtual void NativeOnInitialized() override;
29 virtual void NativeConstruct() override;
30 virtual void NativeDestruct() override;
31
33 DECLARE_DYNAMIC_MULTICAST_DELEGATE_OneParam(FOnSendMessage, const FString&, MessageText);
34 UPROPERTY(BlueprintAssignable)
35 FOnSendMessage OnSendMessage;
36
37 UFUNCTION(BlueprintCallable, Category = "Stream Chat")
38 void EditMessage(const FMessage& Message);
39
40 UFUNCTION()
41 void OnThreadChanged(bool bThreadOpen, const FMessage& ParentMessage);
42
43protected:
44 UPROPERTY(meta = (BindWidget))
45 UMessageInputWidget* MessageInput;
46
47 UPROPERTY(meta = (BindWidget))
48 UIconButton* SendMessageButton;
49
50 UPROPERTY(meta = (BindWidget))
51 UButton* CancelEditingButton;
52
53 UPROPERTY(meta = (BindWidget))
54 UPanelWidget* CancelEditingHeaderPanel;
55
56 UPROPERTY(meta = (BindWidget))
57 UTextBlock* EditMessageTextBlock;
58
59 UPROPERTY(meta = (BindWidget))
60 UBorder* BackgroundBorder;
61
62 UPROPERTY(meta = (BindWidget))
63 UImage* TopBorderImage;
64
65 UPROPERTY(EditAnywhere, Category = "Icon")
66 UTexture2D* IconTextureSend;
67
68 UPROPERTY(EditAnywhere, Category = "Icon")
69 UTexture2D* IconTextureConfirm;
70
71 UPROPERTY(EditAnywhere, Category = "Icon")
72 FMargin IconPaddingSend;
73
74 UPROPERTY(EditAnywhere, Category = "Icon")
75 FMargin IconPaddingConfirm;
76
83 UPROPERTY(EditAnywhere, Category = "Icon")
84 UTexture2D* IconTextureAttach;
85
86 UPROPERTY(EditAnywhere, Category = "Attachment")
87 FVector2D AttachButtonSize = FVector2D{32.f, 32.f};
88
90 UPROPERTY(EditAnywhere, Category = "Thread")
91 FText ThreadHeaderText = NSLOCTEXT("StreamChat", "ReplyingInThread", "Replying in thread");
92
94 UPROPERTY(EditAnywhere, Category = "Attachment", meta = (ClampMin = "0.1", ClampMax = "1.0"))
95 float AttachGlyphScale = 0.5f;
96
98 UPROPERTY(EditAnywhere, Category = "Attachment", meta = (ClampMin = "0.01", ClampMax = "0.5"))
99 float AttachGlyphThickness = 0.06f;
100
101private:
102 UFUNCTION()
103 void OnInputTextChanged(const FText& Text);
104 UFUNCTION()
105 void OnInputTextCommit(const FText& Text, ETextCommit::Type CommitMethod);
106 UFUNCTION()
107 void OnCancelEditingButtonClicked();
108 UFUNCTION()
109 void OnSendButtonClicked();
110 UFUNCTION()
111 void OnAttachButtonClicked();
112
113 void SendMessage();
114 void StopEditMessage();
115 void Keystroke();
116 void StopTyping();
117
119 void CreateAttachmentWidgets();
120 UWidget* BuildAttachIcon();
121 UWidget* BuildAttachGlyph();
122 void Upload(const FPickedAttachment& Picked);
123 void SetStatus(const FString& Status);
124 void UpdateAttachmentAppearance();
125
126 void UpdateSendButtonAppearance(bool bEnabled);
128 void RefreshSendButtonEnabled();
129
130 enum class ESendButtonIconAppearance
131 {
132 Send,
133 Confirm
134 };
135 void UpdateEditMessageAppearance(ESendButtonIconAppearance Appearance);
136
139 void UpdateHeaderBanner();
140
141 TOptional<FMessage> EditedMessage;
142
144 TOptional<FMessage> ThreadParentMessage;
145
147 FText DefaultHeaderText;
148
150 UPROPERTY(Transient)
151 TArray<FAttachment> PendingAttachments;
152
153 // Spawned in C++: WBP_MessageComposer predates attachments and has no slot to bind them to
154 UPROPERTY(Transient)
155 UButton* AttachButton;
157 UPROPERTY(Transient)
158 UWidget* AttachButtonIcon;
160 UPROPERTY(Transient)
161 TArray<UImage*> AttachGlyphBars;
162 UPROPERTY(Transient)
163 UTextBlock* AttachStatusTextBlock;
164
166 bool bUploading = false;
167};
A button with an icon which can be disabled and themed.
Definition IconButton.h:19
@ Text
Text of the message.
@ Type
Type of the message.
Represents a Stream Chat message.
Definition Message.h:70
A file the app picked, ready to be uploaded and attached to a message.
Definition AttachmentPicker.h:12