UDocumentation UE5.7 10.02.2026 (Source)
API documentation for Unreal Engine 5.7
Button.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"
7#include "Input/Reply.h"
9#include "Widgets/SWidget.h"
12
13#include "Button.generated.h"
14
15class SButton;
17
22
31UCLASS(MinimalAPI)
33{
35
36public:
37 UE_DEPRECATED(5.2, "Direct access to WidgetStyle is deprecated. Please use the getter and setter.")
39 UPROPERTY(EditAnywhere, BlueprintReadWrite, Getter = "GetStyle", Setter = "SetStyle", BlueprintSetter = "SetStyle", Category = "Appearance", meta = (DisplayName = "Style"))
40 FButtonStyle WidgetStyle;
41
42 UE_DEPRECATED(5.2, "Direct access to ColorAndOpacity is deprecated. Please use the getter and setter.")
44 UPROPERTY(EditAnywhere, BlueprintReadWrite, Getter, Setter, BlueprintSetter = "SetColorAndOpacity" , Category="Appearance", meta=( sRGB="true" ))
45 FLinearColor ColorAndOpacity;
46
47 UE_DEPRECATED(5.2, "Direct access to BackgroundColor is deprecated. Please use the getter and setter.")
49 UPROPERTY(EditAnywhere, BlueprintReadWrite, Getter, Setter, BlueprintSetter = "SetBackgroundColor", Category="Appearance", meta=( sRGB="true" ))
50 FLinearColor BackgroundColor;
51
52 UE_DEPRECATED(5.2, "Direct access to ClickMethod is deprecated. Please use the getter and setter.")
54 UPROPERTY(EditAnywhere, BlueprintReadWrite, Getter, Setter, BlueprintSetter = "SetClickMethod", Category="Interaction", AdvancedDisplay)
55 TEnumAsByte<EButtonClickMethod::Type> ClickMethod;
56
57 UE_DEPRECATED(5.2, "Direct access to TouchMethod is deprecated. Please use the getter and setter.")
59 UPROPERTY(EditAnywhere, BlueprintReadWrite, Getter, Setter, BlueprintSetter = "SetTouchMethod", Category="Interaction", AdvancedDisplay)
60 TEnumAsByte<EButtonTouchMethod::Type> TouchMethod;
61
62 UE_DEPRECATED(5.2, "Direct access to PressMethod is deprecated. Please use the getter and setter.")
64 UPROPERTY(EditAnywhere, BlueprintReadWrite, Getter, Setter, BlueprintSetter = "SetPressMethod", Category="Interaction", AdvancedDisplay)
65 TEnumAsByte<EButtonPressMethod::Type> PressMethod;
66
67 UE_DEPRECATED(5.2, "Direct access to IsFocusable is deprecated. Please use the getter.")
69 UPROPERTY(EditAnywhere, BlueprintReadOnly, Getter, Category="Interaction")
70 bool IsFocusable;
71
72public:
73
75 UPROPERTY(BlueprintAssignable, Category="Button|Event")
77
79 UPROPERTY(BlueprintAssignable, Category="Button|Event")
81
83 UPROPERTY(BlueprintAssignable, Category="Button|Event")
85
86 UPROPERTY( BlueprintAssignable, Category = "Button|Event" )
88
89 UPROPERTY( BlueprintAssignable, Category = "Button|Event" )
91
93 FOnDragDetected OnButtonDragDetected;
94
96 FOnDragEnter OnButtonDragEnter;
97
99 FOnDragLeave OnButtonDragLeave;
100
102 FOnDragOver OnButtonDragOver;
103
105 FOnDrop OnButtonDrop;
106
108 FSimpleDelegate OnReceivedFocus;
109
111 FSimpleDelegate OnLostFocus;
112
113public:
114
116 UFUNCTION(BlueprintCallable, Category="Button|Appearance")
117 UMG_API void SetStyle(const FButtonStyle& InStyle);
118
119 UMG_API const FButtonStyle& GetStyle() const;
120
122 UFUNCTION(BlueprintCallable, Category="Button|Appearance")
123 UMG_API void SetColorAndOpacity(FLinearColor InColorAndOpacity);
124
125 UMG_API FLinearColor GetColorAndOpacity() const;
126
128 UFUNCTION(BlueprintCallable, Category="Button|Appearance")
129 UMG_API void SetBackgroundColor(FLinearColor InBackgroundColor);
130
131 UMG_API FLinearColor GetBackgroundColor() const;
132
138 UFUNCTION(BlueprintCallable, Category="Button")
139 UMG_API bool IsPressed() const;
140
141 UFUNCTION(BlueprintCallable, Category="Button")
142 UMG_API void SetClickMethod(EButtonClickMethod::Type InClickMethod);
143
144 UMG_API EButtonClickMethod::Type GetClickMethod() const;
145
146 UFUNCTION(BlueprintCallable, Category="Button")
147 UMG_API void SetTouchMethod(EButtonTouchMethod::Type InTouchMethod);
148
149 UMG_API EButtonTouchMethod::Type GetTouchMethod() const;
150
151 UFUNCTION(BlueprintCallable, Category="Button")
152 UMG_API void SetPressMethod(EButtonPressMethod::Type InPressMethod);
153
154 UMG_API EButtonPressMethod::Type GetPressMethod() const;
155
156 UMG_API bool GetIsFocusable() const;
157
158 UFUNCTION(BlueprintCallable, Category="Button")
159 UMG_API void SetAllowDragDrop(bool bInAllowDragDrop);
160
161public:
162
163 //~ Begin UWidget Interface
164 UMG_API virtual void SynchronizeProperties() override;
165 //~ End UWidget Interface
166
167 //~ Begin UVisual Interface
168 UMG_API virtual void ReleaseSlateResources(bool bReleaseChildren) override;
169 //~ End UVisual Interface
170
171 //~ Begin UObject Interface
173 //~ End UObject Interface
174
175#if WITH_EDITOR
176 UMG_API virtual const FText GetPaletteCategory() override;
177#endif
178
179protected:
180
181 // UPanelWidget
182 UMG_API virtual UClass* GetSlotClass() const override;
183 UMG_API virtual void OnSlotAdded(UPanelSlot* Slot) override;
184 UMG_API virtual void OnSlotRemoved(UPanelSlot* Slot) override;
185 // End UPanelWidget
186
187protected:
189 UMG_API FReply SlateHandleClicked();
190 UMG_API void SlateHandlePressed();
191 UMG_API void SlateHandleReleased();
192 UMG_API void SlateHandleHovered();
193 UMG_API void SlateHandleUnhovered();
194 UMG_API void SlateHandleOnReceivedFocus();
195 UMG_API void SlateHandleOnLostFocus();
196
197 // Drag and Drop
198 UMG_API FReply SlateHandleDragDetected(const FGeometry& MyGeometry, const FPointerEvent& MouseEvent);
199 UMG_API void SlateHandleDragEnter(const FGeometry& MyGeometry, const FDragDropEvent& DragDropEvent);
200 UMG_API void SlateHandleDragLeave(const FDragDropEvent& DragDropEvent);
201 UMG_API FReply SlateHandleDragOver(const FGeometry& MyGeometry, const FDragDropEvent& DragDropEvent);
202 UMG_API FReply SlateHandleDrop(const FGeometry& MyGeometry, const FDragDropEvent& DragDropEvent);
203 // End Drag and Drop
204
205 // Initialize IsFocusable in the constructor before the SWidget is constructed.
206 UMG_API void InitIsFocusable(bool InIsFocusable);
207protected:
208 //~ Begin UWidget Interface
209 UMG_API virtual TSharedRef<SWidget> RebuildWidget() override;
210#if WITH_EDITOR
212#endif
213 //~ End UWidget Interface
214
215#if WITH_ACCESSIBILITY
216 UMG_API virtual TSharedPtr<SWidget> GetAccessibleWidget() const override;
217#endif
218
219protected:
222
224 UPROPERTY(EditAnywhere, BlueprintReadOnly, Category="Interaction")
225 bool bAllowDragDrop;
226};
#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
#define DECLARE_DYNAMIC_MULTICAST_DELEGATE(DelegateName)
Definition DelegateCombinations.h:38
return true
Definition ExternalRpcRegistry.cpp:601
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
const FGeometry const FPointerEvent const FDragDropEvent FOnDrop
Definition SlateDelegates.h:44
FOnDragDetected
Definition SlateDelegates.h:24
Definition DragAndDrop.h:141
Definition Reply.h:24
Definition Text.h:385
Definition SButton.h:33
Definition EnumAsByte.h:22
Definition SharedPointer.h:692
Definition SharedPointer.h:153
Definition Button.h:33
TSharedPtr< SButton > MyButton
Definition Button.h:221
Definition Class.h:3793
Definition ContentWidget.h:13
Definition PanelSlot.h:13
Definition SlateWidgetStyleAsset.h:18
const WidgetStyleType * GetStyle() const
Definition SlateWidgetStyleAsset.h:27
Definition SlateEnums.h:13
Definition SlateEnums.h:69
Definition SlateEnums.h:47
Definition SlateTypes.h:509
Definition Geometry.h:40
Definition Color.h:48
Definition Events.h:695