OnBeginCursorOver and OnEndCursorOver Only fired when mouse is clicked over static mesh

Hello, the topic says the main problem. These events get fired only when I have my mouse over my static mesh and when these functions are implemented the OnClicked function doesn’t get fired anymore… I have tried to do this with both c++ and blueprint. I can get the OnClicked event working correctly. I have set the bEnableMouseOverEvents to true in my controller and it is the right controller.

Here is my .h code:

UFUNCTION(Category = Default)
void Numpad1OnClick(UPrimitiveComponent* pComponent, FKey inKey);

UFUNCTION(Category = Default)
void Numpad1OnHover(class UPrimitiveComponent * pComponent);

UFUNCTION(Category = Default)
void Numpad1OnLeave(class UPrimitiveComponent* pComponent);

And here is necessary parts in the cpp

Getting the controller and doing the settings:

APlayerController* controller = UGameplayStatics::GetPlayerController(this->GetWorld(), 0);
controller->bShowMouseCursor = true;
controller->bEnableClickEvents = true;
controller->bEnableMouseOverEvents = true;

Binding functions to events:

numpadKey1->OnClicked.AddDynamic(this, &AAccessPanel::Numpad1OnClick);
numpadKey1->OnBeginCursorOver.AddDynamic(this, &AAccessPanel::Numpad1OnHover);
numpadKey1->OnEndCursorOver.AddDynamic(this, &AAccessPanel::Numpad1OnLeave);

And the functions themselves:

void AAccessPanel::Numpad1OnClick(UPrimitiveComponent * pComponent, FKey inKey)
{
	UE_LOG(LogTemp, Warning, TEXT("Number 1 CLICKed!"));
}

void AAccessPanel::Numpad1OnHover(class UPrimitiveComponent * pComponent)
{
	UE_LOG(LogTemp, Warning, TEXT("Number 1 mouse OVER!"));
}

void AAccessPanel::Numpad1OnLeave(class UPrimitiveComponent * pComponent)
{
	UE_LOG(LogTemp, Warning, TEXT("Number 1 mouse LEFT!"));
}

I have tried changing the collision types of my static mesh but it doesn’t solve this and I think that CursorOver and EndCursorOver should work if OnClicked works? Anything more I can try or is this a bug?

And a little update. I made UBoxComponent and tried to get this working with that but the same problem remains.

And even more info and it gets more weird. If I have bEnableMouseOverEvents enabled but don’t have these events set to be handled my mesh won’t recognice the OnClicked even’t anymore. So only way to recognize OnClicked is to let bEnableMouseOverEvents to be false. Why is this?

perhaps this may help?

I tried setting all the other meshes to ignore all trace and physic channels but the problem remains.

I’m sorry to hear that. This is the code that worked for me immediately without any other change in the actual meshes components, I added it in BeginPlay:

GetCapsuleComponent()->SetCollisionResponseToChannel(ECC_Visibility, ECR_Block);

//add over events

GetCapsuleComponent()->OnClicked.AddDynamic(this, &ADA2UE4Creature::OnClick);

GetCapsuleComponent()->OnBeginCursorOver.AddDynamic(this, &ADA2UE4Creature::BeginCursorOver);

GetCapsuleComponent()->OnEndCursorOver.AddDynamic(this, &ADA2UE4Creature::EndCursorOver);

and in your header file make sure that your functions are marked as UFUNCTION(), but I think you already did that

Thanks!

Finally tested this a bit further. I made a new blank 3rd person project and I got the click, over and end events working as intended in that in both blueprint and c++. I doublechecked my previous project for a chance that there is some collision in front of my event handling collision but there is nothing, not in the world or in my player block the visibility channel before the collision I want to handle the events. I even made a new blank blueprint object with nothing but a single box and event for that and the result was same as before = the mouse over and end events are only handled when mouse is clicked. One notice that I did is that when input mode is set to UiOnly even the clicking doesn’t help, the mode must be set to GameAndUi to even get the events working when clicked. Any ideas?

And more updates. Seems like my code should be fine indeed. Today I noticed that in this project I cannot get the 3d widget ui working like it should and again I got it working in a blank project by following the same steps. So seems like something is messing with the ui interaction in my main project. Any ideas for things i could check? It seems like something in the FInputMode is not working.

I’m sorry, no other ideas :frowning:

Just got it working :slight_smile: I will write about it as an answer.

Finally found the solution. I had to set the visibility of my custom WIDGET to ESlateVisibility::HitTestInvisible. I already had all my texts, buttons etc. set to this inside my widget, but I didn’t know that I had to do it for the widget itself.