UDocumentation UE5.7 10.02.2026 (Source)
API documentation for Unreal Engine 5.7
MenuAnchor.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"
8#include "Widgets/SWidget.h"
10#include "MenuAnchor.generated.h"
11
12class SMenuAnchor;
13
15
22UCLASS(MinimalAPI)
24{
26
27public:
28
30
36 UPROPERTY(EditAnywhere, BlueprintReadOnly, Category="Menu Anchor")
37 TSubclassOf<class UUserWidget> MenuClass;
38
40 UE_DEPRECATED(4.26, "Use OnGetUserMenuContentEvent instead, you may need to make the previous binding return an User Widget.")
41 UPROPERTY(EditAnywhere, Category = "Events", meta = (DeprecationMessage = "4.26. Use OnGetUserMenuContentEvent instead, you may need to make the previous binding return an User Widget."))
42 FGetWidget OnGetMenuContentEvent;
43
45 UPROPERTY(EditAnywhere, Category="Events")
46 FGetUserWidget OnGetUserMenuContentEvent;
47
48 UE_DEPRECATED(5.2, "Direct access to Placement is deprecated. Please use the getter or setter.")
50 UPROPERTY(EditAnywhere, BlueprintReadWrite, Setter, Getter, BlueprintSetter = "SetPlacement", Category = "Menu Anchor")
52
53 UE_DEPRECATED(5.2, "Direct access to bFitInWindow is deprecated. Please use the getter or setter.")
55 UPROPERTY(EditAnywhere, BlueprintReadWrite, Setter = "FitInWindow", Getter = "IsFitInWindow", BlueprintSetter = "FitInWindow", Category = "Menu Anchor", meta = (ScriptName = "ShouldFitInWindow"))
56 bool bFitInWindow;
57
58 UE_DEPRECATED(5.2, "Direct access to ShouldDeferPaintingAfterWindowContent is deprecated. Please use the getter.")
59 UPROPERTY(EditAnywhere, BlueprintReadOnly, Getter = "IsDeferPaintingAfterWindowContent", AdvancedDisplay, Category = "Menu Anchor")
60 bool ShouldDeferPaintingAfterWindowContent;
61
62 UE_DEPRECATED(5.2, "Direct access to UseApplicationMenuStack is deprecated. Please use the getter.")
64 UPROPERTY(EditAnywhere, BlueprintReadOnly, Getter = "IsUseApplicationMenuStack", AdvancedDisplay, Category = "Menu Anchor")
65 bool UseApplicationMenuStack;
66
68 UPROPERTY(EditAnywhere, BlueprintReadOnly, Getter = "IsShowMenuBackground", AdvancedDisplay, Category = "Menu Anchor", meta = (EditCondition = "UseApplicationMenuStack", EditConditionHides, AllowPrivateAccess = "true", DisplayAfter = "UseApplicationMenuStack"))
69 bool ShowMenuBackground;
70
71public:
73 UPROPERTY(BlueprintAssignable, Category="Menu Anchor|Event")
74 FOnMenuOpenChangedEvent OnMenuOpenChanged;
75
76public:
77 //TODO UMG Add Set MenuClass
78
79 UFUNCTION(BlueprintCallable, Category = "Menu Anchor")
80 UMG_API void SetPlacement(EMenuPlacement InPlacement);
81
82 UMG_API EMenuPlacement GetPlacement() const;
83
84 UFUNCTION(BlueprintCallable, Category = "Menu Anchor")
85 UMG_API void FitInWindow(bool bFit);
86
87 UMG_API bool IsFitInWindow() const;
88
89 UMG_API bool IsDeferPaintingAfterWindowContent() const;
90
91 UMG_API bool IsUseApplicationMenuStack() const;
92
93 UMG_API bool IsShowMenuBackground() const;
94
95public:
96
102 UFUNCTION(BlueprintCallable, Category="Menu Anchor")
103 UMG_API void ToggleOpen(bool bFocusOnOpen);
104
106 UFUNCTION(BlueprintCallable, Category="Menu Anchor")
107 UMG_API void Open(bool bFocusMenu);
108
110 UFUNCTION(BlueprintCallable, Category="Menu Anchor")
111 UMG_API void Close();
112
114 UFUNCTION(BlueprintCallable, Category="Menu Anchor")
115 UMG_API bool IsOpen() const;
116
122 UFUNCTION(BlueprintCallable, Category="Menu Anchor")
123 UMG_API bool ShouldOpenDueToClick() const;
124
126 UFUNCTION(BlueprintCallable, Category="Menu Anchor")
127 UMG_API FVector2D GetMenuPosition() const;
128
130 UFUNCTION(BlueprintCallable, Category="Menu Anchor")
131 UMG_API bool HasOpenSubMenus() const;
132
133 UMG_API virtual void ReleaseSlateResources(bool bReleaseChildren) override;
134
135#if WITH_EDITOR
136 UMG_API virtual const FText GetPaletteCategory() override;
137#endif
138
139protected:
140
141 // UPanelWidget
142 UMG_API virtual void OnSlotAdded(UPanelSlot* Slot) override;
143 UMG_API virtual void OnSlotRemoved(UPanelSlot* Slot) override;
144 // End UPanelWidget
145
146 // UWidget interface
147 UMG_API virtual TSharedRef<SWidget> RebuildWidget() override;
148 // End of UWidget interface
149
150 // Initialize ShouldDeferPaintingAfterWindowContent in the constructor before the SWidget is constructed.
151 UMG_API void InitShouldDeferPaintingAfterWindowContent(bool InShouldDeferPaintingAfterWindowContent);
152
153 // Initialize UseApplicationMenuStack in the constructor before the SWidget is constructed.
154 UMG_API void InitUseApplicationMenuStack(bool InUseApplicationMenuStack);
155
156 // Initialize ShowMenuBackground in the constructor before the SWidget is constructed.
157 UMG_API void InitShowMenuBackground(bool InShowMenuBackground);
158
159protected:
160 UMG_API TSharedRef<SWidget> HandleGetMenuContent();
161 UMG_API void HandleMenuOpenChanged(bool bIsOpen);
162
163protected:
165};
UE_FORCEINLINE_HINT TSharedRef< CastToType, Mode > StaticCastSharedRef(TSharedRef< CastFromType, Mode > const &InSharedRef)
Definition SharedPointer.h:127
#define DECLARE_DYNAMIC_MULTICAST_DELEGATE_OneParam(DelegateName, Param1Type, Param1Name)
Definition DelegateCombinations.h:53
return true
Definition ExternalRpcRegistry.cpp:601
JsonWriter Close()
#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
EMenuPlacement
Definition SlateEnums.h:214
Definition UnrealType.h:3087
Definition Text.h:385
Definition EnumAsByte.h:22
Definition SharedPointer.h:692
Definition SharedPointer.h:153
Definition SubclassOf.h:30
Definition ContentWidget.h:13
Definition MenuAnchor.h:24
TSharedPtr< SMenuAnchor > MyMenuAnchor
Definition MenuAnchor.h:164
DECLARE_DYNAMIC_DELEGATE_RetVal(UUserWidget *, FGetUserWidget)
Definition PanelSlot.h:13
Definition UserWidget.h:284