From 407e7e750b2100720bed592c58bb84659810f67a Mon Sep 17 00:00:00 2001 From: Steve Streeting Date: Tue, 8 Oct 2024 16:01:16 +0100 Subject: [PATCH] Add the option to not block clicks through the menu base panel --- Source/StevesUEHelpers/Private/StevesUI/MenuBase.cpp | 2 +- Source/StevesUEHelpers/Public/StevesUI/MenuBase.h | 5 +++++ 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/Source/StevesUEHelpers/Private/StevesUI/MenuBase.cpp b/Source/StevesUEHelpers/Private/StevesUI/MenuBase.cpp index 74fc3d9..d4a6238 100644 --- a/Source/StevesUEHelpers/Private/StevesUI/MenuBase.cpp +++ b/Source/StevesUEHelpers/Private/StevesUI/MenuBase.cpp @@ -105,7 +105,7 @@ void UMenuBase::Open(bool bIsRegain) EmbedInParent(); else AddToViewport(); - SetVisibility(ESlateVisibility::Visible); + SetVisibility(bBlockClicks ? ESlateVisibility::Visible : ESlateVisibility::SelfHitTestInvisible); auto PC = GetOwningPlayer(); switch (InputModeSetting) diff --git a/Source/StevesUEHelpers/Public/StevesUI/MenuBase.h b/Source/StevesUEHelpers/Public/StevesUI/MenuBase.h index 417c10f..3f7f42c 100644 --- a/Source/StevesUEHelpers/Public/StevesUI/MenuBase.h +++ b/Source/StevesUEHelpers/Public/StevesUI/MenuBase.h @@ -45,6 +45,11 @@ protected: UPROPERTY(EditAnywhere, BlueprintReadWrite, Category="Behavior") bool bHideWhenSuperceded = true; + /// Whether this panel should block clicks itself (useful for preventing click-through). + /// Set to false if you want to be able to click through the panel to other elements. + UPROPERTY(EditAnywhere, BlueprintReadWrite, Category="Behavior") + bool bBlockClicks = true; + /// How this menu should set the input mode when it becomes the top of the stack /// This can be useful if your menus have variable input settings between levels in the stack UPROPERTY(EditAnywhere, BlueprintReadWrite, Category="Behavior")