Hi, I’m make a custom k2 node and following K2Node_Select to enable my custom node to add and remove pins.
But, the IK2Node_AddPinInterface
interface only allows adding new pins but not removing pins. As I dive into the source code, I found that the node action “Remove Pin” originated from BlueprintEditor.cpp
, the function CreateGraphEditorWidget.
How can I enable my k2node to remove pins?
Auran131
(Auran13)
September 17, 2025, 10:11am
2
you could probably just call ReconstructNode after changing the pins?
Sulleyyyyyy
(Sulleyyyyyy)
September 17, 2025, 10:49am
3
Well, the point is I cannot find the entry action where I can remove pins, by either right clicking one pin or clicking the node itself.
Auran131
(Auran13)
September 17, 2025, 1:24pm
4
you can create a custom function with CallInEditor that will show up in the details panel.
PREDALIEN
(PREDALIEN)
September 17, 2025, 1:58pm
5
I did it like this:
void UOGNode_ComboGate::GetNodeContextMenuActions(UToolMenu* Menu, UGraphNodeContextMenuContext* Context) const
{
Super::GetNodeContextMenuActions(Menu, Context);
////////////////////////
// Remove selected pin
FToolMenuSection& SectionPin = Menu->FindOrAddSection(FName("EdGraphSchemaPinActions"));
SectionPin.AddDynamicEntry("RemovePinDynamicEntry", FNewToolMenuSectionDelegate::CreateLambda([Context](FToolMenuSection& InSection)
{
FToolUIActionChoice RemovePin_Action(FExecuteAction::CreateLambda([Context]()
{
//UE_LOG(LogTemp, Warning, TEXT("CLICK REMOVE"));
Cast<UOGNode_ComboGate>(Context->Node)->RemoveExecPin(FName(Context->Pin->GetName()));
}));
if (Context->Pin && Context->Pin->Direction == EGPD_Input && Context->Node->Pins.Num() > 3)
{
InSection.AddEntry(FToolMenuEntry::InitMenuEntry(FName("RemovePin"), FText::FromString("Remove Pin"), FText::FromString(TEXT("Remove Pin")), FSlateIcon(FName("OGStyle"), FName("Icons.Remove")), RemovePin_Action));
}
}));
///////////////////////////////////
3 Likes