From 94f144d4e33c8a19306151214fc3967b281ca047 Mon Sep 17 00:00:00 2001 From: Steven Dao Date: Thu, 29 Jul 2021 16:33:46 -0400 Subject: [PATCH] Use right-click to toggle value/array in Partial pin type selector Right-clicking to toggle value/array previously only worked in the Compact type but not in the Full type which has a separate container type button. The Partial selector type is new to UE5 and shows the type icon and name, but no container type button, so enable the right-click behavior for Partial type as well. Practically, this change only affects the My Blueprint tab, which is the only user of ESelectorType::Partial. #jira UE-113633 #rb lauren.barnes #preflight 6102fb982b0028000185c2c9 [CL 17000802 by Steven Dao in ue5-main branch] --- .../KismetWidgets/Private/SPinTypeSelector.cpp | 18 +++++++++++++++--- 1 file changed, 15 insertions(+), 3 deletions(-) diff --git a/Engine/Source/Editor/KismetWidgets/Private/SPinTypeSelector.cpp b/Engine/Source/Editor/KismetWidgets/Private/SPinTypeSelector.cpp index becc8d50cf02..2973610a3934 100644 --- a/Engine/Source/Editor/KismetWidgets/Private/SPinTypeSelector.cpp +++ b/Engine/Source/Editor/KismetWidgets/Private/SPinTypeSelector.cpp @@ -195,6 +195,18 @@ static bool ContainerRequiresGetTypeHash(EPinContainerType InType) return InType == EPinContainerType::Set || InType == EPinContainerType::Map; } +static bool IsRightClickArrayStateToggleEnabled(SPinTypeSelector::ESelectorType SelectorType) +{ + // The Compact and Partial types both allow editing but omit the container-type + // (e.g. value, array) control. For both of these types, enable right-clicking + // on the type combo button to toggle between value/array. + // The None type isn't editable, so it doesn't need this behavior. + // The Full type shows a separate combo button for choosing the container type, + // so it doesn't need this right-click behavior either. + return SelectorType == SPinTypeSelector::ESelectorType::Compact || + SelectorType == SPinTypeSelector::ESelectorType::Partial; +} + TSharedRef SPinTypeSelector::ConstructPinTypeImage(const FSlateBrush* PrimaryIcon, const FSlateColor& PrimaryColor, const FSlateBrush* SecondaryIcon, const FSlateColor& SecondaryColor, TSharedPtr InToolTip) { return @@ -1315,7 +1327,7 @@ FText SPinTypeSelector::GetToolTipForComboBoxType() const FText EditText; if(IsEnabled()) { - if (SelectorType == ESelectorType::Compact) + if (IsRightClickArrayStateToggleEnabled(SelectorType)) { EditText = LOCTEXT("CompactPinTypeSelector", "Left click to select the variable's pin type. Right click to toggle the type as an array.\n"); } @@ -1412,7 +1424,7 @@ FText SPinTypeSelector::GetPinTypeItemCountText() const FReply SPinTypeSelector::OnMouseButtonDown( const FGeometry& MyGeometry, const FPointerEvent& MouseEvent ) { - if (SelectorType == ESelectorType::Compact && MouseEvent.GetEffectingButton() == EKeys::RightMouseButton) + if (IsRightClickArrayStateToggleEnabled(SelectorType) && MouseEvent.GetEffectingButton() == EKeys::RightMouseButton) { bIsRightMousePressed = true; return FReply::Handled(); @@ -1423,7 +1435,7 @@ FReply SPinTypeSelector::OnMouseButtonDown( const FGeometry& MyGeometry, const F FReply SPinTypeSelector::OnMouseButtonUp( const FGeometry& MyGeometry, const FPointerEvent& MouseEvent ) { - if (SelectorType == ESelectorType::Compact && MouseEvent.GetEffectingButton() == EKeys::RightMouseButton) + if (IsRightClickArrayStateToggleEnabled(SelectorType) && MouseEvent.GetEffectingButton() == EKeys::RightMouseButton) { if (bIsRightMousePressed) {