LEAP Documentation 40220
Documentation for the LEAP project
ContextMenuWidget.h
Go to the documentation of this file.
1// Copyright Blue Isle Studios Inc 2018. All Rights Reserved.
2
3#pragma once
4
5#include "CoreMinimal.h"
7#include "ContextMenuWidget.generated.h"
8
9DECLARE_DELEGATE(FDelegateBinding);
10DECLARE_DYNAMIC_DELEGATE(FContextMenuSignature);
11
12USTRUCT(Blueprintable)
14{
15 GENERATED_USTRUCT_BODY()
16
18 {
19 }
20
21 FContextMenuOption(FText InOptionName, FDelegateBinding InDelegateBinding = nullptr)
22 : OptionName(InOptionName)
23 , DelegateOnSelected(InDelegateBinding)
24 {
25 }
26
27public:
28 UPROPERTY(VisibleAnywhere, BlueprintReadOnly, Category = "Context Menu Item")
29 FText OptionName;
30
31 FContextMenuSignature EventOnSelected;
32 FDelegateBinding DelegateOnSelected;
33};
34
35UCLASS()
36class PROJECTX_API UContextMenuWidget : public UAdvancedUserWidget
37{
38 GENERATED_BODY()
39
40public:
41 UFUNCTION(BlueprintImplementableEvent, Category = "Context Menu")
42 void Populate();
43
44 UFUNCTION(BlueprintImplementableEvent, Category = "Context Menu")
45 void SetText(const FText& NewMessage);
46
47 UFUNCTION(BlueprintImplementableEvent, Category = "Context Menu")
48 void SetTitle(const FText& NewMessage);
49
50 UFUNCTION(BlueprintCallable, Category = "Context Menu")
51 void ChooseContextMenuOption(const uint8 ChosenOption, const bool bCloseWindow = true);
52
53 UFUNCTION(BlueprintPure, Category = "Context Menu", meta = (AutoCreateRefTerm = "EventOnSelected"))
54 static FContextMenuOption MakeContextMenuOption(const FText& Text, const FContextMenuSignature& EventOnSelected);
55
56 UPROPERTY(VisibleAnywhere, BlueprintReadOnly, Category= "Context Menu")
57 TArray<FContextMenuOption> ContextMenuItems;
58 UPROPERTY(VisibleAnywhere, BlueprintReadOnly, Category = "Context Menu")
59 FText Title;
60 UPROPERTY(VisibleAnywhere, BlueprintReadOnly, Category = "Context Menu")
61 FText Message;
62
63private:
64 UContextMenuWidget() { bAutoDestroy = true; bDismissableByOtherWidgets = false; }
65};
DECLARE_DYNAMIC_DELEGATE(FContextMenuSignature)
DECLARE_DELEGATE(FDelegateBinding)
Definition: AdvancedUserWidget.h:30
Definition: ContextMenuWidget.h:37
Definition: ContextMenuWidget.h:14
FContextMenuOption(FText InOptionName, FDelegateBinding InDelegateBinding=nullptr)
Definition: ContextMenuWidget.h:21