How to properly setup mouse events in c++?

I’m trying to create some kind of inventory system. Players should be able to select which item in the world they want to pick up by hovering over the item with cursor. In order to check out how OnBeginCursorOver works I created an AActor-derived blueprint with a few nodes that should print a message when the item is being hovered:


This blueprint had a StaticMeshComponent set in blueprint defaults and everything worked as expected.
Then I tried to implement the same behavior in my AWorldItem C++ class.
In the header I added:

void UpdateOutline(AActor* actor);

And in the source:

void AWorldItem::UpdateOutline(AActor* component)
    UE_LOG(LogTemp, Error, TEXT("The item is hovered!"));

Then I try to bind this function in the AWorldItem constructor:

    PrimaryActorTick.bCanEverTick = true;

    MeshComp = CreateDefaultSubobject<UStaticMeshComponent>(TEXT("Mesh"));
    OnBeginCursorOver.AddDynamic(this, &AWorldItem::UpdateOutline);
    OnEndCursorOver.AddDynamic(this, &AWorldItem::UpdateOutline);

MeshComp here is a UStaticMeshComponent and its mesh is being set after the construction.

So, when I hover over the AWorldItem’s MeshComp nothing happens. MeshComp has valid collisions, my player can collide with it. My UI widgets are invisible for mouse event, the AActor-derived blueprint proves that.

I’m stuck here although I followed others’ examples. What do I do wrong?

Added these lines to the constructor, still no luck

    MeshComp->SetCollisionResponseToChannel(ECollisionChannel::ECC_Visibility, ECollisionResponse::ECR_Block);

I don’t know why but everything got working when I changed the mesh. The MeshComp of my item had twin stick example’s UFO static mesh and I changed it to one of mine. I still don’t understand what was wrong with the former mesh.